---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/clotairemit.edu/Dropbox (MIT)/J-PAL Raskin Transition/10_Analysis&Results/Agent Experiment Analysis/03_
> Logs/20240426_udb.log
  log type:  text
 opened on:  26 Apr 2024, 00:07:32

. 
. 
. 
. /*----------------------------------------------------*/
.                 /* Section 0: Setup */
. /*----------------------------------------------------*/
. version 14.2

. clear

. set more off

. 
. // // NOTE: set udb to location of mounted UDB merge data container
. global udb_sep18                          "/Volumes/UDB18"

. global udb_mar19                          "/Volumes/NO NAME"

. 
. 
. /*----------------------------------------------------*/
.         /* Section 2: Clean Sep 18 UDB Merge */
. /*----------------------------------------------------*/
. 
. u "$udb_sep18/SSN_BDT_KOR1809_RT_URUT_FULL.dta", clear

. ds
m101          m1804b        m1904         m2004ak3y     m2004fk1      m302          sumber_pen~n  jumlah_ker~u
m102          m1804c_a      m1905         m2004ak4y     m2004fk2      m303          daya          jumlah_kuda
m103          m1804c_b      m1906a        m2004bk1      m2004fk3      m304          bb_masak      jumlah_babi
m104          m1804c_c      m1906b        m2004bk2      m2004fk4      m305          nomor_gas     jumlah_kam~g
m105          m1804c_d      m1906c        m2004bk3      m2005a_1      fwt           fasbab        sta_art_us~a
nuinfort18    m1805a        m1907a        m2004bk4      m2005a_2      urut2         kloset        sta_kks
m1801a        m1805b        m1907b        m2004ck1b     m2005b        idbdt         buang_tinja   sta_kip
m1801b        m1806a        m1908a        m2004ck2b     m2005c        adapkh        ada_tabung~s  sta_kis
m1801c        m1806b        m1908b        m2004ck3b     m2005d        adakks2016    ada_lemari~s  sta_bpjs_m~i
m1801d        m1807a        m1909         m2004ck4b     m2006a        adakks2017    ada_ac        sta_jamsos~k
m1802         m1807b        m2001         m2004ck1t     m2006b        adapbi        ada_pemanas   sta_asuransi
m1803a_1      m1807c        m2002ak1      m2004ck2t     m2006c        adadapodik    ada_telepon   sta_pkh
m1803a_2      m1807d        m2002ak2      m2004ck3t     m2006d        adabpnt       ada_tv        sta_rastra
m1803b_1      m1807e        m2002ak3      m2004ck4t     m2006e        jumlah_art    ada_emas      sta_kur
m1803b_2      m1807f        m2002ak4      m2004ck1l     m2007         jumlah_kel~a  ada_laptop    sta_kebera~t
m1803c_1      m1808a        m2002bk1      m2004ck2l     m2008         sta_bangunan  ada_sepeda    percentile
m1803c_2      m1808b        m2002bk2      m2004ck3l     m2009a        sta_lahan     ada_motor     id_pengurus
m1803d_1      m1808c        m2002bk3      m2004ck4l     m2009b        luas_lantai   ada_mobil     flag_ada_~15
m1803d_2      m1809a        m2002bk4      m2004dk1      m2010a        lantai        ada_perahu    match_rt
m1803e_1      m1809b        m2003         m2004dk2      m2010b        dinding       ada_motor_~l
m1803e_2      m1809c        m2004ak1      m2004dk3      m2010c        kondisi_di~g  ada_perahu~r
m1803f_1      m1809d        m2004ak2      m2004dk4      m2101a        atap          ada_kapal
m1803f_2      m1810         m2004ak3      m2004ek1      m2101b        kondisi_atap  aset_tak_b~k
m1803g_1      m1901         m2004ak4      m2004ek2      m2101c        jumlah_kamar  luas_atb
m1803g_2      m1902         m2004ak1y     m2004ek3      m203          sumber_air~m  rumah_lain
m1804a        m1903         m2004ak2y     m2004ek4      m301          cara_perol~m  jumlah_sapi

. // drop SUSENAS variables
. count if idbdt != ""
  25,906

. di _N
74019

. // NOTE: 25,906 / 74,019 HHs present in Sep 18 merge
. // subdistrict and village codes only available for matched HHs but are available in separate Sep 18 data set
. 
. keep fwt-match_rt m101-m105

. quietly ds

. di "`r(varlist)'"
m101 m102 m103 m104 m105 fwt urut2 idbdt adapkh adakks2016 adakks2017 adapbi adadapodik adabpnt jumlah_art jumlah_keluarga 
> sta_bangunan sta_lahan luas_lantai lantai dinding kondisi_dinding atap kondisi_atap jumlah_kamar sumber_airminum cara_per
> oleh_airminum sumber_penerangan daya bb_masak nomor_gas fasbab kloset buang_tinja ada_tabung_gas ada_lemari_es ada_ac ada
> _pemanas ada_telepon ada_tv ada_emas ada_laptop ada_sepeda ada_motor ada_mobil ada_perahu ada_motor_tempel ada_perahu_mot
> or ada_kapal aset_tak_bergerak luas_atb rumah_lain jumlah_sapi jumlah_kerbau jumlah_kuda jumlah_babi jumlah_kambing sta_a
> rt_usaha sta_kks sta_kip sta_kis sta_bpjs_mandiri sta_jamsostek sta_asuransi sta_pkh sta_rastra sta_kur sta_keberadaan_rt
>  percentile id_pengurus flag_ada_di_pbdt15 match_rt

. count if idbdt != ""
  25,906

. 
. // Variable: In UDB dummy
. gen udb = idbdt != ""

. tab udb

        udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     48,113       65.00       65.00
          1 |     25,906       35.00      100.00
------------+-----------------------------------
      Total |     74,019      100.00

. tab sta_keberadaan_rt

 Keberadaan |
 ART diluar |
      Rumah |
     Tangga |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         62        2.41        2.41
          1 |      2,437       94.82       97.24
          4 |         60        2.33       99.57
          6 |         11        0.43      100.00
------------+-----------------------------------
      Total |      2,570      100.00

. recode sta_keberadaan_rt (4 6 = .)
(71 changes made to sta_keberadaan_rt)

. 
. *** Set missing to 0, create missing indicator
. foreach var of varlist adapkh adakks2016 adakks2017 adapbi adadapodik sta_keberadaan_rt flag_ada_di_pbdt15 jumlah_sapi ju
> mlah_kerbau jumlah_kuda jumlah_babi jumlah_kambing percentile {
  2.   tab `var'
  3.   // create dummy if var missing
.   gen `var'_m_udb = `var' == .
  4. 
.   // create copy of var where . is set to 0
.   recode `var' (. = 0), gen(`var'_udb)
  5. 
.   tab `var'_udb `var'_m_udb
  6. }

Kepesertaan |
        PKH |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     15,058       58.54       58.54
          1 |     10,664       41.46      100.00
------------+-----------------------------------
      Total |     25,722      100.00
(48,297 differences between adapkh and adapkh_udb)

 RECODE of |
    adapkh |
(Kepeserta |     adapkh_m_udb
   an PKH) |         0          1 |     Total
-----------+----------------------+----------
         0 |    15,058     48,297 |    63,355 
         1 |    10,664          0 |    10,664 
-----------+----------------------+----------
     Total |    25,722     48,297 |    74,019 

Kepemilikan |
   KKS 2016 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     15,128       59.78       59.78
          1 |     10,177       40.22      100.00
------------+-----------------------------------
      Total |     25,305      100.00
(48,714 differences between adakks2016 and adakks2016_udb)

 RECODE of |
adakks2016 |
(Kepemilik |
    an KKS |   adakks2016_m_udb
     2016) |         0          1 |     Total
-----------+----------------------+----------
         0 |    15,128     48,714 |    63,842 
         1 |    10,177          0 |    10,177 
-----------+----------------------+----------
     Total |    25,305     48,714 |    74,019 

Kepemilikan |
   KKS 2017 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     10,009       38.94       38.94
          1 |     15,693       61.06      100.00
------------+-----------------------------------
      Total |     25,702      100.00
(48,317 differences between adakks2017 and adakks2017_udb)

 RECODE of |
adakks2017 |
(Kepemilik |
    an KKS |   adakks2017_m_udb
     2017) |         0          1 |     Total
-----------+----------------------+----------
         0 |    10,009     48,317 |    58,326 
         1 |    15,693          0 |    15,693 
-----------+----------------------+----------
     Total |    25,702     48,317 |    74,019 

Kepesertaan |
        PBI |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     11,315       44.47       44.47
          1 |     14,127       55.53      100.00
------------+-----------------------------------
      Total |     25,442      100.00
(48,577 differences between adapbi and adapbi_udb)

 RECODE of |
    adapbi |
(Kepeserta |     adapbi_m_udb
   an PBI) |         0          1 |     Total
-----------+----------------------+----------
         0 |    11,315     48,577 |    59,892 
         1 |    14,127          0 |    14,127 
-----------+----------------------+----------
     Total |    25,442     48,577 |    74,019 

 Keberadaan |
      dalam |
    Dapodik |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     13,806       54.56       54.56
          1 |     11,499       45.44      100.00
------------+-----------------------------------
      Total |     25,305      100.00
(48,714 differences between adadapodik and adadapodik_udb)

 RECODE of |
adadapodik |
(Keberadaa |
   n dalam |   adadapodik_m_udb
  Dapodik) |         0          1 |     Total
-----------+----------------------+----------
         0 |    13,806     48,714 |    62,520 
         1 |    11,499          0 |    11,499 
-----------+----------------------+----------
     Total |    25,305     48,714 |    74,019 

 Keberadaan |
 ART diluar |
      Rumah |
     Tangga |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         62        2.48        2.48
          1 |      2,437       97.52      100.00
------------+-----------------------------------
      Total |      2,499      100.00
(71,520 differences between sta_keberadaan_rt and sta_keberadaan_rt_udb)

 RECODE of |
sta_kebera |
   daan_rt |
(Keberadaa |
     n ART |
    diluar | sta_keberadaan_rt_m_u
     Rumah |          db
   Tangga) |         0          1 |     Total
-----------+----------------------+----------
         0 |        62     71,520 |    71,582 
         1 |     2,437          0 |     2,437 
-----------+----------------------+----------
     Total |     2,499     71,520 |    74,019 

 Keterangan |
 Keberadaan |
   BDT 2015 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,020        3.94        3.94
          1 |     24,886       96.06      100.00
------------+-----------------------------------
      Total |     25,906      100.00
(48,113 differences between flag_ada_di_pbdt15 and flag_ada_di_pbdt15_udb)

 RECODE of |
flag_ada_d |
  i_pbdt15 |
(Keteranga |
         n | flag_ada_di_pbdt15_m_
Keberadaan |          udb
 BDT 2015) |         0          1 |     Total
-----------+----------------------+----------
         0 |     1,020     48,113 |    49,133 
         1 |    24,886          0 |    24,886 
-----------+----------------------+----------
     Total |    25,906     48,113 |    74,019 

5.4a Jumlah |
       Sapi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      6,406       79.15       79.15
          1 |        789        9.75       88.89
          2 |        528        6.52       95.42
          3 |        182        2.25       97.66
          4 |        100        1.24       98.90
          5 |         37        0.46       99.36
          6 |         20        0.25       99.60
          7 |          6        0.07       99.68
          8 |          7        0.09       99.77
          9 |          3        0.04       99.80
         10 |          6        0.07       99.88
         11 |          1        0.01       99.89
         12 |          2        0.02       99.91
         13 |          2        0.02       99.94
         15 |          2        0.02       99.96
         18 |          2        0.02       99.99
         20 |          1        0.01      100.00
------------+-----------------------------------
      Total |      8,094      100.00
(65,925 differences between jumlah_sapi and jumlah_sapi_udb)

 RECODE of |
jumlah_sap |
   i (5.4a |
    Jumlah |   jumlah_sapi_m_udb
     Sapi) |         0          1 |     Total
-----------+----------------------+----------
         0 |     6,406     65,925 |    72,331 
         1 |       789          0 |       789 
         2 |       528          0 |       528 
         3 |       182          0 |       182 
         4 |       100          0 |       100 
         5 |        37          0 |        37 
         6 |        20          0 |        20 
         7 |         6          0 |         6 
         8 |         7          0 |         7 
         9 |         3          0 |         3 
        10 |         6          0 |         6 
        11 |         1          0 |         1 
        12 |         2          0 |         2 
        13 |         2          0 |         2 
        15 |         2          0 |         2 
        18 |         2          0 |         2 
        20 |         1          0 |         1 
-----------+----------------------+----------
     Total |     8,094     65,925 |    74,019 

5.4b Jumlah |
     Kerbau |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      6,821       97.15       97.15
          1 |         88        1.25       98.40
          2 |         63        0.90       99.30
          3 |         29        0.41       99.72
          4 |          8        0.11       99.83
          5 |          4        0.06       99.89
          6 |          1        0.01       99.90
          8 |          1        0.01       99.91
         12 |          1        0.01       99.93
         13 |          1        0.01       99.94
         18 |          1        0.01       99.96
         20 |          1        0.01       99.97
         24 |          1        0.01       99.99
         54 |          1        0.01      100.00
------------+-----------------------------------
      Total |      7,021      100.00
(66,998 differences between jumlah_kerbau and jumlah_kerbau_udb)

 RECODE of |
jumlah_ker |
 bau (5.4b |
    Jumlah |  jumlah_kerbau_m_udb
   Kerbau) |         0          1 |     Total
-----------+----------------------+----------
         0 |     6,821     66,998 |    73,819 
         1 |        88          0 |        88 
         2 |        63          0 |        63 
         3 |        29          0 |        29 
         4 |         8          0 |         8 
         5 |         4          0 |         4 
         6 |         1          0 |         1 
         8 |         1          0 |         1 
        12 |         1          0 |         1 
        13 |         1          0 |         1 
        18 |         1          0 |         1 
        20 |         1          0 |         1 
        24 |         1          0 |         1 
        54 |         1          0 |         1 
-----------+----------------------+----------
     Total |     7,021     66,998 |    74,019 

5.4c Jumlah |
       Kuda |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      6,862       98.61       98.61
          1 |         65        0.93       99.54
          2 |         16        0.23       99.77
          3 |          7        0.10       99.87
          4 |          6        0.09       99.96
          7 |          2        0.03       99.99
         15 |          1        0.01      100.00
------------+-----------------------------------
      Total |      6,959      100.00
(67,060 differences between jumlah_kuda and jumlah_kuda_udb)

 RECODE of |
jumlah_kud |
   a (5.4c |
    Jumlah |   jumlah_kuda_m_udb
     Kuda) |         0          1 |     Total
-----------+----------------------+----------
         0 |     6,862     67,060 |    73,922 
         1 |        65          0 |        65 
         2 |        16          0 |        16 
         3 |         7          0 |         7 
         4 |         6          0 |         6 
         7 |         2          0 |         2 
        15 |         1          0 |         1 
-----------+----------------------+----------
     Total |     6,959     67,060 |    74,019 

5.4d Jumlah |
       Babi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      6,305       79.36       79.36
          1 |        796       10.02       89.38
          2 |        490        6.17       95.54
          3 |        168        2.11       97.66
          4 |         82        1.03       98.69
          5 |         40        0.50       99.19
          6 |         28        0.35       99.55
          7 |          8        0.10       99.65
          8 |         10        0.13       99.77
          9 |          3        0.04       99.81
         10 |          5        0.06       99.87
         11 |          4        0.05       99.92
         12 |          2        0.03       99.95
         13 |          1        0.01       99.96
         14 |          1        0.01       99.97
         15 |          2        0.03      100.00
------------+-----------------------------------
      Total |      7,945      100.00
(66,074 differences between jumlah_babi and jumlah_babi_udb)

 RECODE of |
jumlah_bab |
   i (5.4d |
    Jumlah |   jumlah_babi_m_udb
     Babi) |         0          1 |     Total
-----------+----------------------+----------
         0 |     6,305     66,074 |    72,379 
         1 |       796          0 |       796 
         2 |       490          0 |       490 
         3 |       168          0 |       168 
         4 |        82          0 |        82 
         5 |        40          0 |        40 
         6 |        28          0 |        28 
         7 |         8          0 |         8 
         8 |        10          0 |        10 
         9 |         3          0 |         3 
        10 |         5          0 |         5 
        11 |         4          0 |         4 
        12 |         2          0 |         2 
        13 |         1          0 |         1 
        14 |         1          0 |         1 
        15 |         2          0 |         2 
-----------+----------------------+----------
     Total |     7,945     66,074 |    74,019 

5.4e Jumlah |
Kambing/Dom |
         ba |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      6,463       80.64       80.64
          1 |        322        4.02       84.65
          2 |        449        5.60       90.26
          3 |        307        3.83       94.09
          4 |        190        2.37       96.46
          5 |        121        1.51       97.97
          6 |         73        0.91       98.88
          7 |         27        0.34       99.21
          8 |         16        0.20       99.41
          9 |         10        0.12       99.54
         10 |         19        0.24       99.78
         11 |          1        0.01       99.79
         12 |          5        0.06       99.85
         15 |          7        0.09       99.94
         16 |          1        0.01       99.95
         17 |          2        0.02       99.98
         20 |          2        0.02      100.00
------------+-----------------------------------
      Total |      8,015      100.00
(66,004 differences between jumlah_kambing and jumlah_kambing_udb)

 RECODE of |
jumlah_kam |
bing (5.4e |
    Jumlah |
Kambing/Do | jumlah_kambing_m_udb
      mba) |         0          1 |     Total
-----------+----------------------+----------
         0 |     6,463     66,004 |    72,467 
         1 |       322          0 |       322 
         2 |       449          0 |       449 
         3 |       307          0 |       307 
         4 |       190          0 |       190 
         5 |       121          0 |       121 
         6 |        73          0 |        73 
         7 |        27          0 |        27 
         8 |        16          0 |        16 
         9 |        10          0 |        10 
        10 |        19          0 |        19 
        11 |         1          0 |         1 
        12 |         5          0 |         5 
        15 |         7          0 |         7 
        16 |         1          0 |         1 
        17 |         2          0 |         2 
        20 |         2          0 |         2 
-----------+----------------------+----------
     Total |     8,015     66,004 |    74,019 

  Persentil |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        712        2.80        2.80
          2 |        730        2.87        5.67
          3 |        682        2.68        8.35
          4 |        591        2.32       10.68
          5 |        684        2.69       13.37
          6 |        609        2.40       15.76
          7 |        667        2.62       18.39
          8 |        598        2.35       20.74
          9 |        557        2.19       22.93
         10 |        575        2.26       25.19
         11 |        557        2.19       27.38
         12 |        595        2.34       29.72
         13 |        562        2.21       31.93
         14 |        552        2.17       34.11
         15 |        610        2.40       36.50
         16 |        570        2.24       38.75
         17 |        535        2.10       40.85
         18 |        529        2.08       42.93
         19 |        556        2.19       45.12
         20 |        531        2.09       47.21
         21 |        560        2.20       49.41
         22 |        540        2.12       51.53
         23 |        542        2.13       53.67
         24 |        525        2.06       55.73
         25 |        554        2.18       57.91
         26 |        502        1.97       59.88
         27 |        518        2.04       61.92
         28 |        545        2.14       64.07
         29 |        469        1.84       65.91
         30 |        472        1.86       67.77
         31 |        510        2.01       69.77
         32 |        494        1.94       71.72
         33 |        435        1.71       73.43
         34 |        426        1.68       75.10
         35 |        303        1.19       76.29
         36 |        286        1.12       77.42
         37 |        266        1.05       78.47
         38 |        262        1.03       79.50
         39 |        239        0.94       80.44
         40 |        278        1.09       81.53
         41 |        238        0.94       82.47
         42 |        227        0.89       83.36
         43 |        205        0.81       84.16
         44 |        217        0.85       85.02
         45 |        208        0.82       85.84
         46 |        189        0.74       86.58
         47 |        182        0.72       87.30
         48 |        184        0.72       88.02
         49 |        190        0.75       88.77
         50 |        173        0.68       89.45
         51 |        177        0.70       90.14
         52 |        180        0.71       90.85
         53 |        194        0.76       91.61
         54 |        159        0.63       92.24
         55 |        156        0.61       92.85
         56 |        125        0.49       93.34
         57 |        116        0.46       93.80
         58 |        122        0.48       94.28
         59 |        124        0.49       94.77
         60 |        127        0.50       95.27
         61 |        105        0.41       95.68
         62 |        113        0.44       96.13
         63 |         86        0.34       96.46
         64 |         93        0.37       96.83
         65 |         95        0.37       97.20
         66 |         77        0.30       97.51
         67 |         91        0.36       97.86
         68 |         77        0.30       98.17
         69 |         63        0.25       98.41
         70 |         62        0.24       98.66
         71 |         68        0.27       98.93
         72 |         53        0.21       99.13
         73 |         46        0.18       99.32
         74 |         36        0.14       99.46
         75 |         67        0.26       99.72
         76 |         13        0.05       99.77
         78 |          4        0.02       99.79
         79 |          2        0.01       99.80
         80 |          2        0.01       99.80
         81 |          1        0.00       99.81
         82 |          1        0.00       99.81
         83 |          2        0.01       99.82
         86 |          2        0.01       99.83
         87 |          1        0.00       99.83
         89 |          1        0.00       99.83
         96 |          1        0.00       99.84
        100 |         41        0.16      100.00
------------+-----------------------------------
      Total |     25,424      100.00
(48,595 differences between percentile and percentile_udb)

 RECODE of |
percentile |
(Persentil |   percentile_m_udb
         ) |         0          1 |     Total
-----------+----------------------+----------
         0 |         0     48,595 |    48,595 
         1 |       712          0 |       712 
         2 |       730          0 |       730 
         3 |       682          0 |       682 
         4 |       591          0 |       591 
         5 |       684          0 |       684 
         6 |       609          0 |       609 
         7 |       667          0 |       667 
         8 |       598          0 |       598 
         9 |       557          0 |       557 
        10 |       575          0 |       575 
        11 |       557          0 |       557 
        12 |       595          0 |       595 
        13 |       562          0 |       562 
        14 |       552          0 |       552 
        15 |       610          0 |       610 
        16 |       570          0 |       570 
        17 |       535          0 |       535 
        18 |       529          0 |       529 
        19 |       556          0 |       556 
        20 |       531          0 |       531 
        21 |       560          0 |       560 
        22 |       540          0 |       540 
        23 |       542          0 |       542 
        24 |       525          0 |       525 
        25 |       554          0 |       554 
        26 |       502          0 |       502 
        27 |       518          0 |       518 
        28 |       545          0 |       545 
        29 |       469          0 |       469 
        30 |       472          0 |       472 
        31 |       510          0 |       510 
        32 |       494          0 |       494 
        33 |       435          0 |       435 
        34 |       426          0 |       426 
        35 |       303          0 |       303 
        36 |       286          0 |       286 
        37 |       266          0 |       266 
        38 |       262          0 |       262 
        39 |       239          0 |       239 
        40 |       278          0 |       278 
        41 |       238          0 |       238 
        42 |       227          0 |       227 
        43 |       205          0 |       205 
        44 |       217          0 |       217 
        45 |       208          0 |       208 
        46 |       189          0 |       189 
        47 |       182          0 |       182 
        48 |       184          0 |       184 
        49 |       190          0 |       190 
        50 |       173          0 |       173 
        51 |       177          0 |       177 
        52 |       180          0 |       180 
        53 |       194          0 |       194 
        54 |       159          0 |       159 
        55 |       156          0 |       156 
        56 |       125          0 |       125 
        57 |       116          0 |       116 
        58 |       122          0 |       122 
        59 |       124          0 |       124 
        60 |       127          0 |       127 
        61 |       105          0 |       105 
        62 |       113          0 |       113 
        63 |        86          0 |        86 
        64 |        93          0 |        93 
        65 |        95          0 |        95 
        66 |        77          0 |        77 
        67 |        91          0 |        91 
        68 |        77          0 |        77 
        69 |        63          0 |        63 
        70 |        62          0 |        62 
        71 |        68          0 |        68 
        72 |        53          0 |        53 
        73 |        46          0 |        46 
        74 |        36          0 |        36 
        75 |        67          0 |        67 
        76 |        13          0 |        13 
        78 |         4          0 |         4 
        79 |         2          0 |         2 
        80 |         2          0 |         2 
        81 |         1          0 |         1 
        82 |         1          0 |         1 
        83 |         2          0 |         2 
        86 |         2          0 |         2 
        87 |         1          0 |         1 
        89 |         1          0 |         1 
        96 |         1          0 |         1 
       100 |        41          0 |        41 
-----------+----------------------+----------
     Total |    25,424     48,595 |    74,019 

. 
. 
. ** BPNT eligibility var
. // NOTE: adabpnt has no 0 for ineligible UDB HHs; I assume all UDB HHs that are missing are 0s
. tab adabpnt

Kepesertaan |
       BPNT |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        900      100.00      100.00
------------+-----------------------------------
      Total |        900      100.00

. gen adabpnt_udb = adabpnt
(73,119 missing values generated)

. 
. // replace missing with 0s
. replace adabpnt_udb = 0 if adabpnt == .
(73,119 real changes made)

. 
. // then create missing var
. gen adabpnt_m_udb = adabpnt_udb == 0 & udb == 0

. tab adabpnt_udb adabpnt_m_udb

adabpnt_ud |     adabpnt_m_udb
         b |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,006     48,113 |    73,119 
         1 |       900          0 |       900 
-----------+----------------------+----------
     Total |    25,906     48,113 |    74,019 

. 
. // rename to shorten
. rename cara_peroleh_airminum caraperolehairmin

. rename sumber_penerangan sumberpen

. 
. // create dummies categories of categorical vars (plus missing)
. foreach var of varlist sta_bangunan sta_lahan lantai dinding atap sumber_airminum caraperolehairmin sumberpen daya bb_mas
> ak fasbab kloset buang_tinja {
  2.   // create indicators for each category
.   tab `var', gen(`var')
  3. 
.   // set missing in each indicator to 0
.   foreach dummy of varlist `var'?* {
  4.     recode `dummy' (. = 0)
  5.     rename `dummy' `dummy'_udb
  6.   }
  7. 
.   // create missing indicator
.   gen `var'_m_udb = `var' == .
  8. 
.   // test that all dummies are exhaustive and mutually exclusive
.   gen test = 0
  9.   foreach testvar of varlist `var'*udb {
 10.     quietly replace test = test + `testvar'
 11.   }
 12.   assert test == 1
 13.   drop test
 14. }

1.a. Status |
Kepemilikan |
   Bangunan |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     22,205       86.59       86.59
          2 |        818        3.19       89.78
          3 |      2,284        8.91       98.69
          4 |         61        0.24       98.92
          5 |        276        1.08      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to sta_bangunan1)
(48,375 changes made to sta_bangunan2)
(48,375 changes made to sta_bangunan3)
(48,375 changes made to sta_bangunan4)
(48,375 changes made to sta_bangunan5)

1.b. Status |
      lahan |
     tempat |
    tinggal |
       yang |
 ditempati: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         83        0.37        0.37
          1 |     19,818       87.59       87.96
          2 |      1,764        7.80       95.76
          3 |        379        1.68       97.43
          4 |        581        2.57      100.00
------------+-----------------------------------
      Total |     22,625      100.00
(51,394 changes made to sta_lahan1)
(51,394 changes made to sta_lahan2)
(51,394 changes made to sta_lahan3)
(51,394 changes made to sta_lahan4)
(51,394 changes made to sta_lahan5)

   3. Jenis |
     lantai |
   terluas: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         51        0.20        0.20
          2 |      3,819       14.89       15.09
          3 |         21        0.08       15.17
          4 |      1,403        5.47       20.64
          5 |        843        3.29       23.93
          6 |     11,319       44.14       68.07
          7 |        417        1.63       69.70
          8 |      4,303       16.78       86.48
          9 |      3,403       13.27       99.75
         10 |         65        0.25      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to lantai1)
(48,375 changes made to lantai2)
(48,375 changes made to lantai3)
(48,375 changes made to lantai4)
(48,375 changes made to lantai5)
(48,375 changes made to lantai6)
(48,375 changes made to lantai7)
(48,375 changes made to lantai8)
(48,375 changes made to lantai9)
(48,375 changes made to lantai10)

 4.a. Jenis |
    dinding |
   terluas: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     12,216       47.64       47.64
          2 |        432        1.68       49.32
          3 |      9,501       37.05       86.37
          4 |      2,021        7.88       94.25
          5 |         48        0.19       94.44
          6 |        620        2.42       96.86
          7 |        806        3.14      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to dinding1)
(48,375 changes made to dinding2)
(48,375 changes made to dinding3)
(48,375 changes made to dinding4)
(48,375 changes made to dinding5)
(48,375 changes made to dinding6)
(48,375 changes made to dinding7)

 5.a. Jenis |
       atap |
   terluas: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        100        0.39        0.39
          2 |         52        0.20        0.59
          3 |        119        0.46        1.06
          4 |      9,931       38.73       39.78
          5 |      1,431        5.58       45.36
          6 |     12,443       48.52       93.89
          7 |        178        0.69       94.58
          8 |         31        0.12       94.70
          9 |      1,314        5.12       99.82
         10 |         45        0.18      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to atap1)
(48,375 changes made to atap2)
(48,375 changes made to atap3)
(48,375 changes made to atap4)
(48,375 changes made to atap5)
(48,375 changes made to atap6)
(48,375 changes made to atap7)
(48,375 changes made to atap8)
(48,375 changes made to atap9)
(48,375 changes made to atap10)

  7. Sumber |
 air minum: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        107        0.42        0.42
          2 |      2,179        8.50        8.91
          3 |      2,222        8.66       17.58
          4 |        601        2.34       19.92
          5 |      3,132       12.21       32.14
          6 |      6,643       25.90       58.04
          7 |      3,372       13.15       71.19
          8 |      3,276       12.77       83.97
          9 |      1,721        6.71       90.68
         10 |      1,287        5.02       95.69
         11 |      1,021        3.98       99.68
         12 |         83        0.32      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to sumber_airminum1)
(48,375 changes made to sumber_airminum2)
(48,375 changes made to sumber_airminum3)
(48,375 changes made to sumber_airminum4)
(48,375 changes made to sumber_airminum5)
(48,375 changes made to sumber_airminum6)
(48,375 changes made to sumber_airminum7)
(48,375 changes made to sumber_airminum8)
(48,375 changes made to sumber_airminum9)
(48,375 changes made to sumber_airminum10)
(48,375 changes made to sumber_airminum11)
(48,375 changes made to sumber_airminum12)

    8. Cara |
 memperoleh |
 air minum: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      3,208       12.51       12.51
          2 |      2,790       10.88       23.39
          3 |     19,646       76.61      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to caraperolehairmin1)
(48,375 changes made to caraperolehairmin2)
(48,375 changes made to caraperolehairmin3)

9.a. Sumber |
 penerangan |
     utama: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     22,437       87.49       87.49
          2 |      1,254        4.89       92.38
          3 |      1,953        7.62      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to sumberpen1)
(48,375 changes made to sumberpen2)
(48,375 changes made to sumberpen3)

  9.b. Jika |
       R.9a |
 berkode 1, |
       daya |
 terpasang: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        339        1.49        1.49
          1 |     13,243       58.11       59.59
          2 |      5,110       22.42       82.01
          3 |        540        2.37       84.38
          4 |         32        0.14       84.52
          5 |          8        0.04       84.56
          6 |      3,519       15.44      100.00
------------+-----------------------------------
      Total |     22,791      100.00
(51,228 changes made to daya1)
(51,228 changes made to daya2)
(51,228 changes made to daya3)
(51,228 changes made to daya4)
(51,228 changes made to daya5)
(51,228 changes made to daya6)
(51,228 changes made to daya7)

  10. Bahan |
bakar/energ |
    i utama |
      untuk |
   memasak: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        115        0.45        0.45
          2 |        340        1.33        1.77
          3 |     10,833       42.24       44.02
          4 |         30        0.12       44.14
          5 |        973        3.79       47.93
          6 |         11        0.04       47.97
          7 |        102        0.40       48.37
          8 |     13,154       51.29       99.66
          9 |         86        0.34      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to bb_masak1)
(48,375 changes made to bb_masak2)
(48,375 changes made to bb_masak3)
(48,375 changes made to bb_masak4)
(48,375 changes made to bb_masak5)
(48,375 changes made to bb_masak6)
(48,375 changes made to bb_masak7)
(48,375 changes made to bb_masak8)
(48,375 changes made to bb_masak9)

      11.a. |
 Penggunaan |
  fasilitas |
     tempat |
  buang air |
     besar: |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     14,716       57.39       57.39
          2 |      3,127       12.19       69.58
          3 |      1,476        5.76       75.34
          4 |      6,325       24.66      100.00
------------+-----------------------------------
      Total |     25,644      100.00
(48,375 changes made to fasbab1)
(48,375 changes made to fasbab2)
(48,375 changes made to fasbab3)
(48,375 changes made to fasbab4)

11.b. Jenis |
    kloset: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        410        2.07        2.07
          1 |     14,163       71.63       73.70
          2 |      1,264        6.39       80.09
          3 |      3,475       17.57       97.67
          4 |        461        2.33      100.00
------------+-----------------------------------
      Total |     19,773      100.00
(54,246 changes made to kloset1)
(54,246 changes made to kloset2)
(54,246 changes made to kloset3)
(54,246 changes made to kloset4)
(54,246 changes made to kloset5)

 12. Tempat |
 pembuangan |
      akhir |
     tinja: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |      9,762       38.07       38.07
          2 |        611        2.38       40.46
          3 |      6,849       26.71       67.16
          4 |      5,737       22.37       89.54
          5 |      2,164        8.44       97.98
          6 |        519        2.02      100.00
------------+-----------------------------------
      Total |     25,643      100.00
(48,376 changes made to buang_tinja1)
(48,376 changes made to buang_tinja2)
(48,376 changes made to buang_tinja3)
(48,376 changes made to buang_tinja4)
(48,376 changes made to buang_tinja5)
(48,376 changes made to buang_tinja6)
(48,376 changes made to buang_tinja7)

. 
. *** Clean 1 = 3 = yes; 2 = 4 = no variables
. * fix unexplained values (do not correspond to survey) in miscellaneous variables
. recode aset_tak_bergerak (61 28 = .)
(2 changes made to aset_tak_bergerak)

. 
. // NOTE: According to the survey, these vars are either 1 = yes, 2 = no; or 3=yes, 4=no; some have all four values mixed 
> in
. // I recode assuming all 1s and 3s are yes, and all 2s and 4s are no
. * Recode yes/no variables
. foreach var of varlist kondisi_dinding kondisi_atap ada_tabung_gas ada_ac ada_telepon ada_emas ada_sepeda ada_motor_tempe
> l sta_art_usaha ///
>   sta_kks sta_kis sta_pkh sta_jamsostek ada_lemari_es ada_pemanas ada_tv ada_laptop ada_motor ada_mobil ada_perahu ada_pe
> rahu_motor ///
>   ada_kapal sta_kip sta_bpjs_mandiri sta_asuransi sta_rastra sta_kur aset_tak_bergerak rumah_lain {
  2.     // NOTE: some vars have 0s when questionnaire indicates answers should only be 1, 2, 3, or 4; I treat 0 as missing
.     replace `var' = . if `var' == 0
  3.     assert inlist(`var', ., 1, 2, 3, 4)
  4. 
.     // recode so 3 => 1 = yes; 2=4 => 0 no
.     recode `var' (3 = 1) (4 2 = 0) (. = 0), gen(`var'_udb)
  5. 
.     // create missing dummy
.     gen `var'_m_udb = `var' == .
  6.     tab `var'_udb `var'_m_udb
  7.     }
(242 real changes made, 242 to missing)
(68,634 differences between kondisi_dinding and kondisi_dinding_udb)

 RECODE of |
kondisi_di |
     nding |
(4.b. Jika |
      R.4a |
berkode 1, |
 2 atau 3, |
   kondisi | kondisi_dinding_m_udb
  dinding) |         0          1 |     Total
-----------+----------------------+----------
         0 |    16,797     51,837 |    68,634 
         1 |     5,385          0 |     5,385 
-----------+----------------------+----------
     Total |    22,182     51,837 |    74,019 
(111 real changes made, 111 to missing)
(67,712 differences between kondisi_atap and kondisi_atap_udb)

 RECODE of |
kondisi_at |
  ap (5.b. |
 Jika R.5a |
berkode 1, |
  2, 3, 4, |
 5, 6 atau |
 7 kondisi |  kondisi_atap_m_udb
         a |         0          1 |     Total
-----------+----------------------+----------
         0 |    17,948     49,764 |    67,712 
         1 |     6,307          0 |     6,307 
-----------+----------------------+----------
     Total |    24,255     49,764 |    74,019 
(0 real changes made)
(73,364 differences between ada_tabung_gas and ada_tabung_gas_udb)

 RECODE of |
ada_tabung |
 _gas (1a. |
Tabung gas |
    5,5 kg |
      atau | ada_tabung_gas_m_udb
    lebih) |         0          1 |     Total
-----------+----------------------+----------
         0 |    24,989     48,375 |    73,364 
         1 |       655          0 |       655 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(73,935 differences between ada_ac and ada_ac_udb)

 RECODE of |
    ada_ac |
    (5.1c. |
Kepemilika |     ada_ac_m_udb
     n AC) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,560     48,375 |    73,935 
         1 |        84          0 |        84 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(73,770 differences between ada_telepon and ada_telepon_udb)

 RECODE of |
ada_telepo |
   n (5.1e |
Kepemilika |
 n Telepon |   ada_telepon_m_udb
    Rumah) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,395     48,375 |    73,770 
         1 |       249          0 |       249 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(72,912 differences between ada_emas and ada_emas_udb)

 RECODE of |
  ada_emas |
     (5.1g |
Kepemilika |
  n Emas > |    ada_emas_m_udb
  10 gram) |         0          1 |     Total
-----------+----------------------+----------
         0 |    24,537     48,375 |    72,912 
         1 |     1,107          0 |     1,107 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(69,038 differences between ada_sepeda and ada_sepeda_udb)

 RECODE of |
ada_sepeda |
     (5.1i |
Kepemilika |   ada_sepeda_m_udb
 n Sepeda) |         0          1 |     Total
-----------+----------------------+----------
         0 |    20,663     48,375 |    69,038 
         1 |     4,981          0 |     4,981 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(73,775 differences between ada_motor_tempel and ada_motor_tempel_udb)

 RECODE of |
ada_motor_ |
    tempel |
     (5.1m |
Kepemilika | ada_motor_tempel_m_ud
   n Motor |           b
   Tempel) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,400     48,375 |    73,775 
         1 |       244          0 |       244 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(295 real changes made, 295 to missing)
(60,599 differences between sta_art_usaha and sta_art_usaha_udb)

 RECODE of |
sta_art_us |
aha (5.5a. |
Apakah ada |
  ART yang |
  memiliki |
     usaha |
sendiri/be |  sta_art_usaha_m_udb
      rsam |         0          1 |     Total
-----------+----------------------+----------
         0 |    11,929     48,670 |    60,599 
         1 |    13,420          0 |    13,420 
-----------+----------------------+----------
     Total |    25,349     48,670 |    74,019 
(3 real changes made, 3 to missing)
(63,298 differences between sta_kks and sta_kks_udb)

 RECODE of |
   sta_kks |
(6a Status |     sta_kks_m_udb
      KKS) |         0          1 |     Total
-----------+----------------------+----------
         0 |    14,920     48,378 |    63,298 
         1 |    10,721          0 |    10,721 
-----------+----------------------+----------
     Total |    25,641     48,378 |    74,019 
(0 real changes made)
(59,595 differences between sta_kis and sta_kis_udb)

 RECODE of |
   sta_kis |
(6c Status |     sta_kis_m_udb
      KIS) |         0          1 |     Total
-----------+----------------------+----------
         0 |    11,220     48,375 |    59,595 
         1 |    14,424          0 |    14,424 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(71,987 differences between sta_pkh and sta_pkh_udb)

 RECODE of |
   sta_pkh |
(6g Status |     sta_pkh_m_udb
      PKH) |         0          1 |     Total
-----------+----------------------+----------
         0 |    23,611     48,375 |    71,986 
         1 |     2,033          0 |     2,033 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(73,623 differences between sta_jamsostek and sta_jamsostek_udb)

 RECODE of |
sta_jamsos |
   tek (6e |
    Status |
      BPJS |
Ketenagake |  sta_jamsostek_m_udb
    rjaan) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,248     48,375 |    73,623 
         1 |       396          0 |       396 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,018 differences between ada_lemari_es and ada_lemari_es_udb)

 RECODE of |
ada_lemari |
_es (5.1b. |
    Lemari |  ada_lemari_es_m_udb
Es/Kulkas) |         0          1 |     Total
-----------+----------------------+----------
         0 |    20,139     48,375 |    68,514 
         1 |     5,505          0 |     5,505 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,019 differences between ada_pemanas and ada_pemanas_udb)

 RECODE of |
ada_pemana |
  s (5.1d. |
Kepemilika |
 n Pemanas |   ada_pemanas_m_udb
      Air) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,505     48,375 |    73,880 
         1 |       139          0 |       139 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,014 differences between ada_tv and ada_tv_udb)

 RECODE of |
    ada_tv |
     (5.1f |
Kepemilika |
         n |     ada_tv_m_udb
 Televisi) |         0          1 |     Total
-----------+----------------------+----------
         0 |     7,775     48,375 |    56,150 
         1 |    17,869          0 |    17,869 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,019 differences between ada_laptop and ada_laptop_udb)

 RECODE of |
ada_laptop |
     (5.1h |
Kepemilika |   ada_laptop_m_udb
 n Laptop) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,109     48,375 |    73,484 
         1 |       535          0 |       535 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,017 differences between ada_motor and ada_motor_udb)

 RECODE of |
 ada_motor |
     (5.1j |
Kepemilika |
  n Sepeda |    ada_motor_m_udb
    Motor) |         0          1 |     Total
-----------+----------------------+----------
         0 |    12,624     48,375 |    60,999 
         1 |    13,020          0 |    13,020 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(73,760 differences between ada_mobil and ada_mobil_udb)

 RECODE of |
 ada_mobil |
     (5.1k |
Kepemilika |    ada_mobil_m_udb
  n Mobil) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,385     48,375 |    73,760 
         1 |       259          0 |       259 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,019 differences between ada_perahu and ada_perahu_udb)

 RECODE of |
ada_perahu |
     (5.1l |
Kepemilika |   ada_perahu_m_udb
 n Perahu) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,049     48,375 |    73,424 
         1 |       595          0 |       595 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,019 differences between ada_perahu_motor and ada_perahu_motor_udb)

 RECODE of |
ada_perahu |
    _motor |
     (5.1n |
Kepemilika | ada_perahu_motor_m_ud
  n Perahu |           b
    Motor) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,434     48,375 |    73,809 
         1 |       210          0 |       210 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,009 differences between ada_kapal and ada_kapal_udb)

 RECODE of |
 ada_kapal |
     (5.1o |
Kepemilika |    ada_kapal_m_udb
  n Kapal) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,634     48,375 |    74,009 
         1 |        10          0 |        10 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(3 real changes made, 3 to missing)
(74,019 differences between sta_kip and sta_kip_udb)

 RECODE of |
   sta_kip |
(6b Status |     sta_kip_m_udb
      KIP) |         0          1 |     Total
-----------+----------------------+----------
         0 |    22,480     48,378 |    70,858 
         1 |     3,161          0 |     3,161 
-----------+----------------------+----------
     Total |    25,641     48,378 |    74,019 
(6 real changes made, 6 to missing)
(74,017 differences between sta_bpjs_mandiri and sta_bpjs_mandiri_udb)

 RECODE of |
sta_bpjs_m |
andiri (6d |
    Status | sta_bpjs_mandiri_m_ud
      BPJS |           b
  Mandiri) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,086     48,381 |    73,467 
         1 |       552          0 |       552 
-----------+----------------------+----------
     Total |    25,638     48,381 |    74,019 
(0 real changes made)
(74,018 differences between sta_asuransi and sta_asuransi_udb)

 RECODE of |
sta_asuran |
    si (6f |
    Status |  sta_asuransi_m_udb
 Asuransi) |         0          1 |     Total
-----------+----------------------+----------
         0 |    24,089     48,375 |    72,464 
         1 |     1,555          0 |     1,555 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(74,012 differences between sta_rastra and sta_rastra_udb)

 RECODE of |
sta_rastra |
(6h Status |   sta_rastra_m_udb
   Rastra) |         0          1 |     Total
-----------+----------------------+----------
         0 |     6,502     48,375 |    54,877 
         1 |    19,142          0 |    19,142 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(73,619 differences between sta_kur and sta_kur_udb)

 RECODE of |
   sta_kur |
(6i Status |     sta_kur_m_udb
      KUR) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,244     48,375 |    73,619 
         1 |       400          0 |       400 
-----------+----------------------+----------
     Total |    25,644     48,375 |    74,019 
(0 real changes made)
(53,085 differences between aset_tak_bergerak and aset_tak_bergerak_udb)

 RECODE of |
aset_tak_b |
   ergerak |
     (5.3a | aset_tak_bergerak_m_u
Kepemilika |          db
  n Lahan) |         0          1 |     Total
-----------+----------------------+----------
         0 |     4,708     48,377 |    53,085 
         1 |    20,934          0 |    20,934 
-----------+----------------------+----------
     Total |    25,642     48,377 |    74,019 
(4 real changes made, 4 to missing)
(74,018 differences between rumah_lain and rumah_lain_udb)

 RECODE of |
rumah_lain |
     (5.3b |
Kepemilika |
   n Rumah |   rumah_lain_m_udb
     Lain) |         0          1 |     Total
-----------+----------------------+----------
         0 |    25,413     48,379 |    73,792 
         1 |       227          0 |       227 
-----------+----------------------+----------
     Total |    25,640     48,379 |    74,019 

. 
. *** Leftover variables
. /*
> jumlah_art jumlah_keluarga luas_lantai jumlah_kamar nomor_gas aset_tak_bergerak luas_atb rumah_lain jumlah_sapi jumlah_ke
> rbau jumlah_kuda
> jumlah_babi jumlah_kambing sta_kur sta_keberadaan_rt percentile id_pengurus flag_ada_di_pbdt15
> */
. 
. ** jumlah_art: number of HH members
. // create dummies, treating as categorical variable to allow it to enter flexibly (10+ combined)
. tab jumlah_art, gen(jumlah_art)

     Jumlah |
    Anggota |
      Rumah |
     Tangga |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      1,027        3.96        3.96
          2 |      2,910       11.23       15.20
          3 |      4,951       19.11       34.31
          4 |      6,672       25.75       60.06
          5 |      4,745       18.32       78.38
          6 |      2,773       10.70       89.08
          7 |      1,431        5.52       94.61
          8 |        745        2.88       97.48
          9 |        329        1.27       98.75
         10 |        210        0.81       99.56
         11 |         50        0.19       99.76
         12 |         31        0.12       99.88
         13 |         17        0.07       99.94
         14 |          5        0.02       99.96
         15 |          3        0.01       99.97
         16 |          2        0.01       99.98
         18 |          3        0.01       99.99
         19 |          1        0.00      100.00
         22 |          1        0.00      100.00
------------+-----------------------------------
      Total |     25,906      100.00

. 
. // Create indicator for 10+ category
. gen jumlah_art10up_udb = jumlah_art10 == 1 | jumlah_art11 == 1 | jumlah_art12 == 1 | jumlah_art13 == 1 | jumlah_art14 == 
> 1 | jumlah_art15 == 1 | ///
>   jumlah_art16 == 1 | jumlah_art17 == 1 | jumlah_art18 == 1 | jumlah_art19 == 1

. tab jumlah_art10up_udb

jumlah_art1 |
    0up_udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     73,696       99.56       99.56
          1 |        323        0.44      100.00
------------+-----------------------------------
      Total |     74,019      100.00

. 
. // set missings to 0
. forvalues i  = 1 / 9 {
  2.   recode jumlah_art`i' (. = 0)
  3.   rename jumlah_art`i' jumlah_art`i'_udb
  4. }
(48,113 changes made to jumlah_art1)
(48,113 changes made to jumlah_art2)
(48,113 changes made to jumlah_art3)
(48,113 changes made to jumlah_art4)
(48,113 changes made to jumlah_art5)
(48,113 changes made to jumlah_art6)
(48,113 changes made to jumlah_art7)
(48,113 changes made to jumlah_art8)
(48,113 changes made to jumlah_art9)

. 
. // create missing indicator
. gen jumlah_art_m_udb = jumlah_art == .

. 
. 
. ** jumlah_keluarga: number of families in HH
. // by my reading, 0 families should be impossible (every individual belongs to a family); I recode to 0
. replace jumlah_keluarga = . if jumlah_keluarga == 0
(4 real changes made, 4 to missing)

. 
. // create dummies
. tab jumlah_keluarga, gen(jumlah_keluarga)

     Jumlah |
   Keluarga |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     23,320       90.04       90.04
          2 |      2,305        8.90       98.93
          3 |        226        0.87       99.81
          4 |         32        0.12       99.93
          5 |          9        0.03       99.97
          6 |          5        0.02       99.98
          7 |          2        0.01       99.99
          8 |          2        0.01      100.00
------------+-----------------------------------
      Total |     25,901      100.00

. 
. // create indicator for 4+ category
. gen jumlah_keluarga4up_udb = jumlah_keluarga4 == 1 | jumlah_keluarga5 == 1 | jumlah_keluarga6 == 1 | jumlah_keluarga7 == 
> 1 | jumlah_keluarga8 == 1

. 
. // set missings to 0
. forvalues i  = 1 / 3 {
  2.   recode jumlah_keluarga`i' (. = 0)
  3.   rename jumlah_keluarga`i' jumlah_keluarga`i'_udb
  4. }
(48,118 changes made to jumlah_keluarga1)
(48,118 changes made to jumlah_keluarga2)
(48,118 changes made to jumlah_keluarga3)

. 
. // create missing indicator
. gen jumlah_keluarga_m_udb = jumlah_keluarga == .

. tab jumlah_keluarga_m_udb

jumlah_kelu |
 arga_m_udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     25,901       34.99       34.99
          1 |     48,118       65.01      100.00
------------+-----------------------------------
      Total |     74,019      100.00

. 
. 
. ** luas_lantai: floor area
. destring luas_lantai, replace
luas_lantai: all characters numeric; replaced as int
(48375 missing values generated)

. summ luas_lantai

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 luas_lantai |     25,644    51.29601    29.85773          0        900

. recode luas_lantai (. = 0), gen(luas_lantai_udb)
(48,375 differences between luas_lantai and luas_lantai_udb)

. 
. // missing indicator
. gen luas_lantai_m_udb = luas_lantai == .

. 
. 
. ** jumlah_kamar: number of rooms
. // create dummies, treating as categorical variable (4+ combined)
. tab jumlah_kamar, gen(jumlah_kamar)

  6. Jumlah |
      kamar |
     tidur: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        934        3.64        3.64
          1 |      6,334       24.71       28.35
          2 |     11,807       46.06       74.41
          3 |      5,602       21.85       96.26
          4 |        808        3.15       99.41
          5 |        111        0.43       99.84
          6 |         26        0.10       99.95
          7 |          6        0.02       99.97
          8 |          2        0.01       99.98
          9 |          1        0.00       99.98
         12 |          1        0.00       99.98
         23 |          1        0.00       99.99
         35 |          1        0.00       99.99
         60 |          1        0.00      100.00
         70 |          1        0.00      100.00
------------+-----------------------------------
      Total |     25,636      100.00

. 
. // rename dummies to match values
. forval i = 1 / 15 {
  2.   local j = `i' - 1
  3.   rename jumlah_kamar`i' jumlah_kamar`j'
  4. }

. 
. // create 4+ category
. gen jumlah_kamar4up_udb = jumlah_kamar4 == 1| jumlah_kamar5 == 1 | jumlah_kamar6 == 1 | jumlah_kamar7 == 1 | jumlah_kamar
> 8 == 1 | jumlah_kamar9 == 1 | ///
>   jumlah_kamar10 == 1 | jumlah_kamar11 == 1 | jumlah_kamar12 == 1 | jumlah_kamar13 == 1 | jumlah_kamar14 == 1

. tab jumlah_kamar4up_udb

jumlah_kama |
   r4up_udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     73,060       98.70       98.70
          1 |        959        1.30      100.00
------------+-----------------------------------
      Total |     74,019      100.00

. 
. // recode missings to 0
. forval i = 0 / 3 {
  2.   recode jumlah_kamar`i' (. = 0)
  3.   rename jumlah_kamar`i' jumlah_kamar`i'_udb
  4. }
(48,383 changes made to jumlah_kamar0)
(48,383 changes made to jumlah_kamar1)
(48,383 changes made to jumlah_kamar2)
(48,383 changes made to jumlah_kamar3)

. 
. // create missing indicator
. gen jumlah_kamar_m_udb = jumlah_kamar == .

. 
. summ jumlah_kamar*udb

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
jumlah~0_udb |     74,019    .0126184    .1116214          0          1
jumla~r1_udb |     74,019    .0855726    .2797338          0          1
jumla~r2_udb |     74,019    .1595131    .3661564          0          1
jumla~r3_udb |     74,019    .0756833    .2644925          0          1
jum~r4up_udb |     74,019    .0129561     .113086          0          1
-------------+---------------------------------------------------------
juml~r_m_udb |     74,019    .6536565    .4758075          0          1

. 
. 
. ** luas_atb: land area
. replace luas_atb = "" if luas_atb == "-"
(26 real changes made)

. destring luas_atb, replace
luas_atb: all characters numeric; replaced as long
(52085 missing values generated)

. 
. // examine outliers in luas_atb
. summ luas_atb, d

                       5.3a Luas Lahan
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%           20              0
10%           40              0       Obs              21,934
25%           84              0       Sum of wgt.      21,934

50%          350                      Mean            3126.09
                        Largest       Std. dev.      7021.606
75%         2587          99998
90%        10000          99998       Variance       4.93e+07
95%        15000          99998       Skewness       5.057618
99%        32030          99998       Kurtosis       41.47444

. gen luas_atb_z = (luas_atb - `r(mean)') / `r(sd)'
(52,085 missing values generated)

. summ luas_atb_z

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  luas_atb_z |     21,934    3.23e-09           1  -.4452101   13.79626

. cap noi extremes luas_atb luas_atb_z, high n(25)

  +------------------------------+
  |   obs:   luas_atb   luas_a~z |
  |------------------------------|
  | 15529.      70150   9.545382 |
  | 51355.      71300   9.709163 |
  | 51352.      71444   9.729671 |
  | 50196.      75000   10.23611 |
  | 61240.      75000   10.23611 |
  |------------------------------|
  | 63564.      75000   10.23611 |
  | 47030.      75400   10.29307 |
  |  1001.      80000    10.9482 |
  |  3539.      80000    10.9482 |
  | 12834.      80000    10.9482 |
  |------------------------------|
  | 12914.      80000    10.9482 |
  | 13249.      80000    10.9482 |
  | 15589.      80000    10.9482 |
  | 48453.      80000    10.9482 |
  | 64348.      80000    10.9482 |
  |------------------------------|
  | 51358.      81150   11.11198 |
  | 52560.      90000   12.37237 |
  | 55396.      90300    12.4151 |
  |   533.      93804   12.91413 |
  | 17057.      98000   13.51171 |
  |------------------------------|
  | 11540.      99998   13.79626 |
  | 16518.      99998   13.79626 |
  | 53117.      99998   13.79626 |
  | 53142.      99998   13.79626 |
  | 54564.      99998   13.79626 |
  +------------------------------+

. 
. // winsorize luas_atb
. gen luas_atb_udb = luas_atb
(52,085 missing values generated)

. _pctile luas_atb, p(99.5)

. replace luas_atb_udb = `r(r1)' if luas_atb_udb > `r(r1)' & !missing(luas_atb_udb)
(82 real changes made)

. summ luas_atb_udb

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
luas_atb_udb |     21,934    3068.262    6493.264          0      50000

. 
. // Create missing luas_atb variable
. gen luas_atb_m_udb = luas_atb == .

. tab luas_atb_m_udb

luas_atb_m_ |
        udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     21,934       29.63       29.63
          1 |     52,085       70.37      100.00
------------+-----------------------------------
      Total |     74,019      100.00

. 
. // Replace . = 0
. replace luas_atb_udb = 0 if luas_atb_udb == .
(52,085 real changes made)

. 
. *** Keep lasso-prepped vars, save dataset
. keep urut2 *udb

. 
. tempfile sep18_rt

. save `sep18_rt'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.000001 saved as .dta format

. 
. 
. *** Create Head of HH variables from individual survey
. u "$udb_sep18/SSN_BDT_KOR1809_ID_FULL.dta", clear

. keep fwt-source_name

. ds
fwt           tgllahir      sta_kawin     jenis_cacat   ijazah_ter~i  sta_kebera~t  ada_pkh       omset_usaha
urut2         hub_krt       ada_akta_n~h  penyakit_k~s  sta_bekerja   sta_kepese~i  ada_rastra    flag_ada_~15
idbdt         nuk           ada_dikk      partisipas~h  jumlah_jam~a  ada_kks       lapangan_u~t  match
idartbdt      hubkel        ada_kartu_~s  pendidikan~i  lapangan_u~a  ada_pbi       jumlah_pek~a  source_nik
jnskel        umur          sta_hamil     kelas_tert~i  status_pek~n  ada_kip       lokasi_usaha  source_name

. 
. * Head of HH
. gen head_hh = hub_krt == 1

. tab head_hh

    head_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    258,279       93.10       93.10
          1 |     19,143        6.90      100.00
------------+-----------------------------------
      Total |    277,422      100.00

. 
. * Age of head of HH
. gen age = umur if head_hh == 1
(258,283 missing values generated)

. summ age

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
         age |     19,139    48.46413    12.96355          0         98

. 
. * keep only head of HH observations
. // some HHs report more than one HoH for some reason
. // when this is the case, I make the oldest one the head of household
. bysort urut2: egen head_hh_check = total(head_hh)

. count if head_hh_check > 1
  1,800

. 
. bysort urut2 (age): gen head_hh_fix = _n == _N if head_hh == 1
(258,279 missing values generated)

. tab head_hh_fix head_hh

head_hh_fi |  head_hh
         x |         1 |     Total
-----------+-----------+----------
         0 |    18,081 |    18,081 
         1 |     1,062 |     1,062 
-----------+-----------+----------
     Total |    19,143 |    19,143 

. replace head_hh = head_hh_fix if head_hh_check > 1
(1,783 real changes made, 1,130 to missing)

. tab head_hh_fix head_hh

head_hh_fi |        head_hh
         x |         0          1 |     Total
-----------+----------------------+----------
         0 |       653     17,428 |    18,081 
         1 |         0      1,062 |     1,062 
-----------+----------------------+----------
     Total |       653     18,490 |    19,143 

. 
. keep if head_hh == 1
(258,932 observations deleted)

. 
. * Male head of HH
. gen male = jnskel == 1

. replace male = . if jnskel == .
(9 real changes made, 9 to missing)

. 
. * HoH marital status
. tab sta_kawin, gen(sta_kawin)

  sta_kawin |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        257        1.40        1.40
          2 |     14,814       80.60       82.00
          3 |        562        3.06       85.05
          4 |      2,747       14.95      100.00
------------+-----------------------------------
      Total |     18,380      100.00

. 
. * education level of edu reached
. tab pendidikan_tertinggi

pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        200        1.19        1.19
          1 |     10,480       62.27       63.46
          2 |         60        0.36       63.81
          3 |        192        1.14       64.96
          4 |      3,030       18.00       82.96
          5 |         42        0.25       83.21
          6 |        125        0.74       83.95
          7 |      2,396       14.24       98.19
          8 |         63        0.37       98.56
          9 |         65        0.39       98.95
         10 |        157        0.93       99.88
         99 |         20        0.12      100.00
------------+-----------------------------------
      Total |     16,830      100.00

. recode pendidikan_tertinggi (99 = .)
(20 changes made to pendidikan_tertinggi)

. tab pendidikan_tertinggi, gen(pendidikan_tertinggi)

pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        200        1.19        1.19
          1 |     10,480       62.34       63.53
          2 |         60        0.36       63.89
          3 |        192        1.14       65.03
          4 |      3,030       18.02       83.06
          5 |         42        0.25       83.31
          6 |        125        0.74       84.05
          7 |      2,396       14.25       98.30
          8 |         63        0.37       98.68
          9 |         65        0.39       99.07
         10 |        157        0.93      100.00
------------+-----------------------------------
      Total |     16,810      100.00

. summ pendidikan_tertinggi?*

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
pendidika~i1 |     16,810    .0118977    .1084289          0          1
pendidikan~2 |     16,810    .6234384    .4845378          0          1
pendidikan~3 |     16,810    .0035693    .0596387          0          1
pendidikan~4 |     16,810    .0114218    .1062638          0          1
pendidikan~5 |     16,810    .1802499    .3844069          0          1
-------------+---------------------------------------------------------
pendidikan~6 |     16,810    .0024985    .0499241          0          1
pendidikan~7 |     16,810     .007436    .0859139          0          1
pendidikan~8 |     16,810    .1425342    .3496076          0          1
pendidikan~9 |     16,810    .0037478     .061106          0          1
pendidika~10 |     16,810    .0038667    .0620647          0          1
-------------+---------------------------------------------------------
pendidika~11 |     16,810    .0093397    .0961925          0          1

. 
. * highest grade ever reached
. tab kelas_tertinggi, gen(kelas_tertinggi)

kelas_terti |
       nggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        201        1.19        1.19
          1 |        665        3.95        5.15
          2 |      1,086        6.45       11.60
          3 |      1,104        6.56       18.16
          4 |        766        4.55       22.71
          5 |        820        4.87       27.59
          6 |        471        2.80       30.39
          7 |          3        0.02       30.40
          8 |     11,711       69.60      100.00
------------+-----------------------------------
      Total |     16,827      100.00

. 
. * highest diploma received
. tab ijazah_tertinggi, gen(ijazah_tertinggi)

ijazah_tert |
      inggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      3,944       23.44       23.44
          1 |      7,109       42.25       65.69
          2 |      3,130       18.60       84.29
          3 |      2,369       14.08       98.37
          4 |        187        1.11       99.48
          5 |         80        0.48       99.95
          6 |          8        0.05      100.00
------------+-----------------------------------
      Total |     16,827      100.00

. 
. * work status
. tab sta_bekerja

sta_bekerja |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          4        0.02        0.02
          1 |     15,641       85.10       85.12
          2 |      2,735       14.88      100.00
------------+-----------------------------------
      Total |     18,380      100.00

. gen worked = sta_bekerja == 1

. replace worked = . if sta_bekerja == .
(110 real changes made, 110 to missing)

. 
. * hours worked
. summ jumlah_jamkerja

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
jumlah_jam~a |     16,020    36.03714    17.35976          0         98

. 
. * field of business
. tab lapangan_usaha

lapangan_us |
        aha |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        376        2.35        2.35
          1 |      4,503       28.10       30.45
          2 |        396        2.47       32.92
          3 |      3,136       19.57       52.49
          4 |        610        3.81       56.30
          5 |         87        0.54       56.84
          6 |        305        1.90       58.75
          7 |        179        1.12       59.86
          8 |        208        1.30       61.16
          9 |        797        4.97       66.14
         10 |         29        0.18       66.32
         11 |      1,655       10.33       76.65
         12 |      1,054        6.58       83.22
         13 |        166        1.04       84.26
         14 |        753        4.70       88.96
         15 |         12        0.07       89.03
         16 |         16        0.10       89.13
         17 |         82        0.51       89.65
         18 |         11        0.07       89.71
         19 |      1,023        6.38       96.10
         20 |         64        0.40       96.50
         21 |        561        3.50      100.00
------------+-----------------------------------
      Total |     16,023      100.00

. recode lapangan_usaha (0 = .)
(376 changes made to lapangan_usaha)

. tab lapangan_usaha, gen(lapangan_usaha)

lapangan_us |
        aha |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      4,503       28.78       28.78
          2 |        396        2.53       31.31
          3 |      3,136       20.04       51.35
          4 |        610        3.90       55.25
          5 |         87        0.56       55.81
          6 |        305        1.95       57.76
          7 |        179        1.14       58.90
          8 |        208        1.33       60.23
          9 |        797        5.09       65.32
         10 |         29        0.19       65.51
         11 |      1,655       10.58       76.08
         12 |      1,054        6.74       82.82
         13 |        166        1.06       83.88
         14 |        753        4.81       88.69
         15 |         12        0.08       88.77
         16 |         16        0.10       88.87
         17 |         82        0.52       89.40
         18 |         11        0.07       89.47
         19 |      1,023        6.54       96.01
         20 |         64        0.41       96.41
         21 |        561        3.59      100.00
------------+-----------------------------------
      Total |     15,647      100.00

. 
. * job status
. tab status_pekerjaan

status_peke |
      rjaan |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        376        2.35        2.35
          1 |      5,143       32.10       34.45
          2 |      3,821       23.85       58.29
          3 |        241        1.50       59.80
          4 |      3,032       18.92       78.72
          5 |         22        0.14       78.86
          6 |      1,708       10.66       89.52
          7 |      1,506        9.40       98.92
          8 |        173        1.08      100.00
------------+-----------------------------------
      Total |     16,022      100.00

. recode status_pekerjaan (0 = .)
(376 changes made to status_pekerjaan)

. tab status_pekerjaan, gen(status_pekerjaan)

status_peke |
      rjaan |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      5,143       32.87       32.87
          2 |      3,821       24.42       57.29
          3 |        241        1.54       58.83
          4 |      3,032       19.38       78.21
          5 |         22        0.14       78.35
          6 |      1,708       10.92       89.27
          7 |      1,506        9.63       98.89
          8 |        173        1.11      100.00
------------+-----------------------------------
      Total |     15,646      100.00

. 
. keep urut2 status_pekerjaan?* lapangan_usaha? lapangan_usaha?? worked jumlah_jamkerja ijazah_tertinggi? kelas_tertinggi? 
> ///
>   pendidikan_tertinggi? pendidikan_tertinggi?? sta_kawin male age

. rename * *_hoh_udb

. rename urut2_hoh_udb urut2

. 
. tempfile head_hh_sep18

. save `head_hh_sep18'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.000002 saved as .dta format

. 
. 
. *** Create overall household variables from individual survey
. u "$udb_sep18/SSN_BDT_KOR1809_ID_FULL.dta", clear

. keep fwt-source_name

. ds
fwt           tgllahir      sta_kawin     jenis_cacat   ijazah_ter~i  sta_kebera~t  ada_pkh       omset_usaha
urut2         hub_krt       ada_akta_n~h  penyakit_k~s  sta_bekerja   sta_kepese~i  ada_rastra    flag_ada_~15
idbdt         nuk           ada_dikk      partisipas~h  jumlah_jam~a  ada_kks       lapangan_u~t  match
idartbdt      hubkel        ada_kartu_~s  pendidikan~i  lapangan_u~a  ada_pbi       jumlah_pek~a  source_nik
jnskel        umur          sta_hamil     kelas_tert~i  status_pek~n  ada_kip       lokasi_usaha  source_name

. gen udb = idbdt != ""

. keep if udb == 1
(208,896 observations deleted)

. 
. * pregnancy status
. tab sta_hamil

  sta_hamil |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      4,847       26.76       26.76
          1 |        569        3.14       29.90
          2 |     12,696       70.10      100.00
------------+-----------------------------------
      Total |     18,112      100.00

. gen pregnant = sta_hamil == 1

. gen pregnant_m = sta_hamil == .

. 
. * disability type
. tab jenis_cacat

jenis_cacat |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     67,034       98.62       98.62
          1 |        252        0.37       98.99
          2 |        119        0.18       99.16
          3 |         86        0.13       99.29
          4 |         67        0.10       99.39
          5 |         43        0.06       99.45
          6 |         20        0.03       99.48
          7 |          8        0.01       99.49
          8 |         25        0.04       99.53
          9 |         17        0.03       99.55
         10 |        124        0.18       99.74
         11 |         65        0.10       99.83
         12 |        114        0.17      100.00
------------+-----------------------------------
      Total |     67,974      100.00

. gen disability = 1 <= jenis_cacat & jenis_cacat <= 12

. gen disability_m = jenis_cacat == .

. 
. * chronic disease
. tab penyakit_kronis

penyakit_kr |
       onis |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     65,051       95.70       95.70
          1 |        660        0.97       96.67
          2 |        982        1.44       98.12
          3 |        368        0.54       98.66
          4 |         98        0.14       98.80
          5 |        138        0.20       99.00
          6 |         64        0.09       99.10
          7 |        131        0.19       99.29
          8 |         45        0.07       99.36
          9 |        437        0.64      100.00
------------+-----------------------------------
      Total |     67,974      100.00

. gen chronic_disease = 1 <= penyakit_kronis & penyakit_kronis <= 9

. gen chronic_disease_m = penyakit_kronis == .

. 
. * number in school
. gen in_school = partisipasi_sekolah == 1

. gen in_school_m = partisipasi_sekolah == .

. 
. * highest level of education completed
. tab pendidikan_tertinggi

pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,129        1.92        1.92
          1 |     32,816       55.92       57.85
          2 |        229        0.39       58.24
          3 |        749        1.28       59.51
          4 |     11,598       19.76       79.28
          5 |         96        0.16       79.44
          6 |        804        1.37       80.81
          7 |      9,529       16.24       97.05
          8 |        163        0.28       97.33
          9 |        385        0.66       97.98
         10 |        983        1.68       99.66
         99 |        200        0.34      100.00
------------+-----------------------------------
      Total |     58,681      100.00

. recode pendidikan_tertinggi (99 = .)
(200 changes made to pendidikan_tertinggi)

. 
. * highest grade ever reached
. tab kelas_tertinggi

kelas_terti |
       nggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,133        1.93        1.93
          1 |      5,532        9.43       11.36
          2 |      6,284       10.71       22.07
          3 |      5,706        9.73       31.80
          4 |      3,178        5.42       37.21
          5 |      3,498        5.96       43.17
          6 |      2,523        4.30       47.47
          7 |         46        0.08       47.55
          8 |     30,771       52.45      100.00
------------+-----------------------------------
      Total |     58,671      100.00

. 
. * highest degree
. tab ijazah_tertinggi

ijazah_tert |
      inggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     18,238       31.09       31.09
          1 |     20,864       35.56       66.65
          2 |     10,458       17.82       84.47
          3 |      7,972       13.59       98.06
          4 |        727        1.24       99.30
          5 |        367        0.63       99.92
          6 |         45        0.08      100.00
------------+-----------------------------------
      Total |     58,671      100.00

. 
. * worked in past week
. tab sta_bekerja

sta_bekerja |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        104        0.16        0.16
          1 |     28,806       45.06       45.22
          2 |     35,015       54.78      100.00
------------+-----------------------------------
      Total |     63,925      100.00

. gen work = sta_bekerja
(4,601 missing values generated)

. recode work (2 = 0)
(35,015 changes made to work)

. gen work_m = sta_bekerja == .

. 
. * number in HH
. preserve

. bysort urut2: gen num_in_hh = _N

. summ num_in_hh

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
   num_in_hh |     68,526    3.414821    1.522591          1         10

. keep urut2 num_in_hh

. duplicates drop

Duplicates in terms of all variables

(42,563 observations deleted)

. di _N
25963

. tempfile num_hh

. save `num_hh'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.000004 saved as .dta format

. restore

. 
. // merge in number in HH
. merge m:1 urut2 using `num_hh'

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                            68,526  (_merge==3)
    -----------------------------------------

. assert _m != 2

. drop _m

. 
. tab num_in_hh, gen(num_in_hh)

  num_in_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      6,856       10.00       10.00
          2 |     12,880       18.80       28.80
          3 |     17,724       25.86       54.67
          4 |     16,260       23.73       78.39
          5 |      8,815       12.86       91.26
          6 |      3,888        5.67       96.93
          7 |      1,351        1.97       98.90
          8 |        512        0.75       99.65
          9 |        180        0.26       99.91
         10 |         60        0.09      100.00
------------+-----------------------------------
      Total |     68,526      100.00

. 
. // keep vars
. keep urut2 pregnant disability chronic_disease in_school work pendidikan_tertinggi kelas_tertinggi ijazah_tertinggi num_i
> n_hh? num_in_hh?? *_m

. 
. 
. // collapse to HH level
. collapse (sum) pregnant disability chronic_disease in_school work (max) max_edu_in_hh = pendidikan_tertinggi max_grade_in
> _hh = kelas_tertinggi ///
>   max_degree_in_hh = ijazah_tertinggi (mean) num_in_hh? num_in_hh?? *_m, by(urut2)

. summ

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       urut2 |     25,963    35584.56    20838.63          2      73948
    pregnant |     25,963    .0219158     .147721          0          2
  disability |     25,963    .0362054    .1995649          0          3
chronic_di~e |     25,963    .1125833    .3785277          0          6
   in_school |     25,963    .6215383    .8552785          0          9
-------------+---------------------------------------------------------
        work |     25,963    1.109502    .8358375          0          7
max_edu_in~h |     24,353    4.005133    2.803215          0         10
max_grade_~h |     24,380    6.926907    2.086561          0          8
max_degree~h |     24,380    1.720016    1.145382          0          6
  num_in_hh1 |     25,963    .2640681    .4408442          0          1
-------------+---------------------------------------------------------
  num_in_hh2 |     25,963    .2480453    .4318866          0          1
  num_in_hh3 |     25,963    .2275546    .4192616          0          1
  num_in_hh4 |     25,963     .156569    .3634009          0          1
  num_in_hh5 |     25,963    .0679043    .2515865          0          1
  num_in_hh6 |     25,963    .0249586    .1560019          0          1
-------------+---------------------------------------------------------
  num_in_hh7 |     25,963    .0074337    .0858992          0          1
  num_in_hh8 |     25,963     .002465     .049589          0          1
  num_in_hh9 |     25,963    .0007703    .0277446          0          1
 num_in_hh10 |     25,963    .0002311    .0152004          0          1
  pregnant_m |     25,963    .7475608    .3312874          0          1
-------------+---------------------------------------------------------
disability_m |     25,963    .0107838    .0991109          0          1
chronic_di~m |     25,963    .0107838    .0991109          0          1
 in_school_m |     25,963     .057723    .1627316          0          1
      work_m |     25,963    .0578296    .1627934          0          1

. di _N
25963

. * Create education variables categories
. tab max_edu_in_hh, gen(max_edu_in_hh)

      (max) |
pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        167        0.69        0.69
          1 |      9,193       37.75       38.43
          2 |        113        0.46       38.90
          3 |        297        1.22       40.12
          4 |      5,881       24.15       64.27
          5 |         72        0.30       64.56
          6 |        504        2.07       66.63
          7 |      6,773       27.81       94.44
          8 |        145        0.60       95.04
          9 |        332        1.36       96.40
         10 |        876        3.60      100.00
------------+-----------------------------------
      Total |     24,353      100.00

. tab max_grade_in_hh, gen(max_grade_in_hh)

      (max) |
kelas_terti |
       nggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        170        0.70        0.70
          1 |        644        2.64        3.34
          2 |        967        3.97        7.31
          3 |      1,172        4.81       12.11
          4 |        883        3.62       15.73
          5 |      1,118        4.59       20.32
          6 |        865        3.55       23.87
          7 |         16        0.07       23.93
          8 |     18,545       76.07      100.00
------------+-----------------------------------
      Total |     24,380      100.00

. tab max_degree_in_hh, gen(max_degree_in_hh)

      (max) |
ijazah_tert |
      inggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      3,486       14.30       14.30
          1 |      8,089       33.18       47.48
          2 |      5,935       24.34       71.82
          3 |      5,913       24.25       96.07
          4 |        589        2.42       98.49
          5 |        328        1.35       99.84
          6 |         40        0.16      100.00
------------+-----------------------------------
      Total |     24,380      100.00

. 
. * Create 1+ in HH dummy
. foreach var of varlist pregnant disability chronic_disease in_school work {
  2.   gen `var'_hh = `var' >= 1
  3.   // replace = missing if all obs within HH are missing
.   replace `var'_hh = . if `var'_m == 1
  4.   tab `var'_hh
  5. }
(12,612 real changes made, 12,612 to missing)

pregnant_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     12,787       95.78       95.78
          1 |        564        4.22      100.00
------------+-----------------------------------
      Total |     13,351      100.00
(238 real changes made, 238 to missing)

disability_ |
         hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     24,844       96.58       96.58
          1 |        881        3.42      100.00
------------+-----------------------------------
      Total |     25,725      100.00
(238 real changes made, 238 to missing)

chronic_dis |
    ease_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     23,302       90.58       90.58
          1 |      2,423        9.42      100.00
------------+-----------------------------------
      Total |     25,725      100.00
(388 real changes made, 388 to missing)

in_school_h |
          h |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     14,430       56.42       56.42
          1 |     11,145       43.58      100.00
------------+-----------------------------------
      Total |     25,575      100.00
(388 real changes made, 388 to missing)

    work_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      5,555       21.72       21.72
          1 |     20,020       78.28      100.00
------------+-----------------------------------
      Total |     25,575      100.00

. 
. keep urut2 pregnant_hh disability_hh chronic_disease_hh in_school_hh work_hh max_edu_in_hh? max_edu_in_hh?? max_grade_in_
> hh? max_degree_in_hh? num_in_hh? num_in_hh??

. rename * *_udb

. rename urut2_udb urut2

. 
. tempfile overall_hh_sep18

. save `overall_hh_sep18'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.000005 saved as .dta format

. 
. ** Merge in vars from individual datasets
. u `sep18_rt', clear

. 
. * merge in Head of HH vars
. merge 1:1 urut2 using `head_hh_sep18'

    Result                      Number of obs
    -----------------------------------------
    Not matched                        55,529
        from master                    55,529  (_merge==1)
        from using                          0  (_merge==2)

    Matched                            18,490  (_merge==3)
    -----------------------------------------

. assert _m != 2

. drop _m

. 
. // create missing indicators
. foreach stub in status_pekerjaan lapangan_usaha ijazah_tertinggi kelas_tertinggi pendidikan_tertinggi {
  2.   gen `stub'_hoh_m_udb = `stub'1_hoh_udb == .
  3.   summ `stub'_hoh_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
status~m_udb |     74,019    .7886218    .4082887          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
lapang~m_udb |     74,019    .7886083    .4082983          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
ijazah~m_udb |     74,019    .7726665    .4191126          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
kelas_~m_udb |     74,019    .7726665    .4191126          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
pendid~m_udb |     74,019    .7728961    .4189631          0          1

. 
. foreach stub in worked jumlah_jamkerja sta_kawin male age {
  2.   gen `stub'_hoh_m_udb = `stub'_hoh_udb == .
  3.   summ `stub'_hoh_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
worked~m_udb |     74,019    .7516854    .4320382          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
juml~h_m_udb |     74,019    .7835691    .4118141          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
sta_ka~m_udb |     74,019    .7516854    .4320382          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
male_hoh_m~b |     74,019    .7503209    .4328302          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
age_hoh_m_~b |     74,019    .7502533    .4328693          0          1

. 
. // replace missings with 0s
. foreach var of varlist status_pekerjaan?_hoh_udb lapangan_usaha?_hoh_udb lapangan_usaha??_hoh_udb ijazah_tertinggi?_hoh_u
> db kelas_tertinggi?_hoh_udb ///
>   pendidikan_tertinggi?_hoh_udb pendidikan_tertinggi??_hoh_udb worked_hoh_udb jumlah_jamkerja_hoh_udb sta_kawin_hoh_udb m
> ale_hoh_udb age_hoh_udb {
  2.     recode `var' (. = 0)
  3.   }
(58,373 changes made to status_pekerjaan1_hoh_udb)
(58,373 changes made to status_pekerjaan2_hoh_udb)
(58,373 changes made to status_pekerjaan3_hoh_udb)
(58,373 changes made to status_pekerjaan4_hoh_udb)
(58,373 changes made to status_pekerjaan5_hoh_udb)
(58,373 changes made to status_pekerjaan6_hoh_udb)
(58,373 changes made to status_pekerjaan7_hoh_udb)
(58,373 changes made to status_pekerjaan8_hoh_udb)
(58,372 changes made to lapangan_usaha1_hoh_udb)
(58,372 changes made to lapangan_usaha2_hoh_udb)
(58,372 changes made to lapangan_usaha3_hoh_udb)
(58,372 changes made to lapangan_usaha4_hoh_udb)
(58,372 changes made to lapangan_usaha5_hoh_udb)
(58,372 changes made to lapangan_usaha6_hoh_udb)
(58,372 changes made to lapangan_usaha7_hoh_udb)
(58,372 changes made to lapangan_usaha8_hoh_udb)
(58,372 changes made to lapangan_usaha9_hoh_udb)
(58,372 changes made to lapangan_usaha10_hoh_udb)
(58,372 changes made to lapangan_usaha11_hoh_udb)
(58,372 changes made to lapangan_usaha12_hoh_udb)
(58,372 changes made to lapangan_usaha13_hoh_udb)
(58,372 changes made to lapangan_usaha14_hoh_udb)
(58,372 changes made to lapangan_usaha15_hoh_udb)
(58,372 changes made to lapangan_usaha16_hoh_udb)
(58,372 changes made to lapangan_usaha17_hoh_udb)
(58,372 changes made to lapangan_usaha18_hoh_udb)
(58,372 changes made to lapangan_usaha19_hoh_udb)
(58,372 changes made to lapangan_usaha20_hoh_udb)
(58,372 changes made to lapangan_usaha21_hoh_udb)
(57,192 changes made to ijazah_tertinggi1_hoh_udb)
(57,192 changes made to ijazah_tertinggi2_hoh_udb)
(57,192 changes made to ijazah_tertinggi3_hoh_udb)
(57,192 changes made to ijazah_tertinggi4_hoh_udb)
(57,192 changes made to ijazah_tertinggi5_hoh_udb)
(57,192 changes made to ijazah_tertinggi6_hoh_udb)
(57,192 changes made to ijazah_tertinggi7_hoh_udb)
(57,192 changes made to kelas_tertinggi1_hoh_udb)
(57,192 changes made to kelas_tertinggi2_hoh_udb)
(57,192 changes made to kelas_tertinggi3_hoh_udb)
(57,192 changes made to kelas_tertinggi4_hoh_udb)
(57,192 changes made to kelas_tertinggi5_hoh_udb)
(57,192 changes made to kelas_tertinggi6_hoh_udb)
(57,192 changes made to kelas_tertinggi7_hoh_udb)
(57,192 changes made to kelas_tertinggi8_hoh_udb)
(57,192 changes made to kelas_tertinggi9_hoh_udb)
(57,209 changes made to pendidikan_tertinggi1_hoh_udb)
(57,209 changes made to pendidikan_tertinggi2_hoh_udb)
(57,209 changes made to pendidikan_tertinggi3_hoh_udb)
(57,209 changes made to pendidikan_tertinggi4_hoh_udb)
(57,209 changes made to pendidikan_tertinggi5_hoh_udb)
(57,209 changes made to pendidikan_tertinggi6_hoh_udb)
(57,209 changes made to pendidikan_tertinggi7_hoh_udb)
(57,209 changes made to pendidikan_tertinggi8_hoh_udb)
(57,209 changes made to pendidikan_tertinggi9_hoh_udb)
(57,209 changes made to pendidikan_tertinggi10_hoh_udb)
(57,209 changes made to pendidikan_tertinggi11_hoh_udb)
(55,639 changes made to worked_hoh_udb)
(57,999 changes made to jumlah_jamkerja_hoh_udb)
(55,639 changes made to sta_kawin_hoh_udb)
(55,538 changes made to male_hoh_udb)
(55,533 changes made to age_hoh_udb)

. 
. * merge in overall HH vars
. merge 1:1 urut2 using `overall_hh_sep18'

    Result                      Number of obs
    -----------------------------------------
    Not matched                        48,056
        from master                    48,056  (_merge==1)
        from using                          0  (_merge==2)

    Matched                            25,963  (_merge==3)
    -----------------------------------------

. assert _m != 2

. drop _m

. 
. // create missing indicators
. foreach stub in pregnant_hh disability_hh chronic_disease_hh in_school_hh work_hh {
  2.   gen `stub'_m_udb = `stub'_udb == .
  3.   summ `stub'_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
pregna~m_udb |     74,019    .8196274    .3845001          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
disabi~m_udb |     74,019    .6524541    .4761941          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
chroni~m_udb |     74,019    .6524541    .4761941          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
in_sch~m_udb |     74,019    .6544806    .4755405          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
work_hh_m_~b |     74,019    .6544806    .4755405          0          1

. 
. foreach stub in max_edu_in_hh max_grade_in_hh max_degree_in_hh num_in_hh {
  2.   gen `stub'_m_udb = `stub'1_udb == .
  3.   summ `stub'_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
max_ed~m_udb |     74,019    .6709899    .4698568          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
max_gr~m_udb |     74,019    .6706251    .4699894          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
max_de~m_udb |     74,019    .6706251    .4699894          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
num_in_hh_~b |     74,019    .6492387    .4772116          0          1

. 
. // replace missings with 0s
. foreach var of varlist pregnant_hh_udb disability_hh_udb chronic_disease_hh_udb in_school_hh_udb work_hh_udb max_edu_in_h
> h?_udb max_edu_in_hh??_udb ///
>   max_grade_in_hh?_udb max_degree_in_hh?_udb num_in_hh?_udb num_in_hh??_udb {
  2.     recode `var' (. = 0)
  3.   }
(60,668 changes made to pregnant_hh_udb)
(48,294 changes made to disability_hh_udb)
(48,294 changes made to chronic_disease_hh_udb)
(48,444 changes made to in_school_hh_udb)
(48,444 changes made to work_hh_udb)
(49,666 changes made to max_edu_in_hh1_udb)
(49,666 changes made to max_edu_in_hh2_udb)
(49,666 changes made to max_edu_in_hh3_udb)
(49,666 changes made to max_edu_in_hh4_udb)
(49,666 changes made to max_edu_in_hh5_udb)
(49,666 changes made to max_edu_in_hh6_udb)
(49,666 changes made to max_edu_in_hh7_udb)
(49,666 changes made to max_edu_in_hh8_udb)
(49,666 changes made to max_edu_in_hh9_udb)
(49,666 changes made to max_edu_in_hh10_udb)
(49,666 changes made to max_edu_in_hh11_udb)
(0 changes made to max_edu_in_hh_m_udb)
(49,639 changes made to max_grade_in_hh1_udb)
(49,639 changes made to max_grade_in_hh2_udb)
(49,639 changes made to max_grade_in_hh3_udb)
(49,639 changes made to max_grade_in_hh4_udb)
(49,639 changes made to max_grade_in_hh5_udb)
(49,639 changes made to max_grade_in_hh6_udb)
(49,639 changes made to max_grade_in_hh7_udb)
(49,639 changes made to max_grade_in_hh8_udb)
(49,639 changes made to max_grade_in_hh9_udb)
(49,639 changes made to max_degree_in_hh1_udb)
(49,639 changes made to max_degree_in_hh2_udb)
(49,639 changes made to max_degree_in_hh3_udb)
(49,639 changes made to max_degree_in_hh4_udb)
(49,639 changes made to max_degree_in_hh5_udb)
(49,639 changes made to max_degree_in_hh6_udb)
(49,639 changes made to max_degree_in_hh7_udb)
(48,056 changes made to num_in_hh1_udb)
(48,056 changes made to num_in_hh2_udb)
(48,056 changes made to num_in_hh3_udb)
(48,056 changes made to num_in_hh4_udb)
(48,056 changes made to num_in_hh5_udb)
(48,056 changes made to num_in_hh6_udb)
(48,056 changes made to num_in_hh7_udb)
(48,056 changes made to num_in_hh8_udb)
(48,056 changes made to num_in_hh9_udb)
(48,056 changes made to num_in_hh10_udb)
(0 changes made to num_in_hh_m_udb)

. 
. // assert no missings
. foreach var of varlist *udb {
  2.   assert `var' != .
  3. }

. 
. ds
urut2         lantai1_udb   sumb~m_m_udb  buang_~5_udb  ada_pe~u_udb  jum~r4up_udb  l~a7_hoh_udb  num_in~0_udb
udb           lantai2_udb   carape~1_udb  buang_~6_udb  ada_~u_m_udb  juml~r_m_udb  l~a8_hoh_udb  max_e~h1_udb
adapkh_m_udb  lantai3_udb   carape~2_udb  buang_~7_udb  ada_pe~r_udb  luas_atb_udb  l~a9_hoh_udb  max_ed~2_udb
adapkh_udb    lantai4_udb   carape~3_udb  buang_~m_udb  ada_perahu..  luas_atb_m~b  l~10_hoh_udb  max_ed~3_udb
adak~6_m_udb  lantai5_udb   carape~m_udb  kondis~g_udb  ada_ka~l_udb  sta_ka~h_udb  l~11_hoh_udb  max_ed~4_udb
adakks~6_udb  lantai6_udb   sumberpen1~b  kond~g_m_udb  ada_ka~m_udb  jumlah~h_udb  l~12_hoh_udb  max_ed~5_udb
adak~7_m_udb  lantai7_udb   sumberpen2~b  kondis~p_udb  sta_kip_udb   age_hoh_udb   l~13_hoh_udb  max_ed~6_udb
adakks~7_udb  lantai8_udb   sumberpen3~b  kond~p_m_udb  sta_kip_m_~b  male_hoh_udb  l~14_hoh_udb  max_ed~7_udb
adapbi_m_udb  lantai9_udb   sumberpen_~b  ada_ta~s_udb  sta_bp~i_udb  p~i1_hoh_udb  l~15_hoh_udb  max_ed~8_udb
adapbi_udb    lantai10_udb  daya1_udb     ada_ta~m_udb  sta_bp~m_udb  pe~2_hoh_udb  l~16_hoh_udb  max_ed~9_udb
adadap~m_udb  lantai_m_udb  daya2_udb     ada_ac_udb    sta_as~i_udb  pe~3_hoh_udb  l~17_hoh_udb  max_ed~0_udb
adadap~k_udb  dinding1_udb  daya3_udb     ada_ac_m_udb  sta_as~m_udb  pe~4_hoh_udb  l~18_hoh_udb  max_e~11_udb
sta_ke~m_udb  dinding2_udb  daya4_udb     ada_te~n_udb  sta_ra~a_udb  pe~5_hoh_udb  l~19_hoh_udb  max_gr~1_udb
sta_ke~t_udb  dinding3_udb  daya5_udb     ada_te~m_udb  sta_ra~m_udb  pe~6_hoh_udb  l~20_hoh_udb  max_gr~2_udb
flag_a~m_udb  dinding4_udb  daya6_udb     ada_emas_udb  sta_kur_udb   pe~7_hoh_udb  l~21_hoh_udb  max_gr~3_udb
flag_a~5_udb  dinding5_udb  daya7_udb     ada_emas_m~b  sta_kur_m_~b  pe~8_hoh_udb  st~1_hoh_udb  max_gr~4_udb
jum~pi_m_udb  dinding6_udb  daya_m_udb    ada_se~a_udb  aset_t~k_udb  pe~9_hoh_udb  st~2_hoh_udb  max_gr~5_udb
jumla~pi_udb  dinding7_udb  bb_masak1_~b  ada_se~m_udb  aset_t~m_udb  pe~0_hoh_udb  st~3_hoh_udb  max_gr~6_udb
juml~u_m_udb  dinding_m_~b  bb_masak2_~b  ada_m~el_udb  rumah_~n_udb  p~11_hoh_udb  st~4_hoh_udb  max_gr~7_udb
jumlah~u_udb  atap1_udb     bb_masak3_~b  ada~el_m_udb  rumah_~m_udb  ke~1_hoh_udb  st~5_hoh_udb  max_gr~8_udb
jum~da_m_udb  atap2_udb     bb_masak4_~b  sta_ar~a_udb  jumla~t1_udb  ke~2_hoh_udb  st~6_hoh_udb  max_gr~9_udb
jumlah~a_udb  atap3_udb     bb_masak5_~b  sta_ar~m_udb  jumla~t2_udb  ke~3_hoh_udb  st~7_hoh_udb  max_de~1_udb
jum~bi_m_udb  atap4_udb     bb_masak6_~b  sta_kks_udb   jumla~t3_udb  ke~4_hoh_udb  st~8_hoh_udb  max_de~2_udb
jumla~bi_udb  atap5_udb     bb_masak7_~b  sta_kks_m_~b  jumlah~4_udb  ke~5_hoh_udb  status~m_udb  max_de~3_udb
juml~g_m_udb  atap6_udb     bb_masak8_~b  sta_kis_udb   jumlah~5_udb  ke~6_hoh_udb  lapang~m_udb  max_de~4_udb
jumlah~g_udb  atap7_udb     bb_masak9_~b  sta_kis_m_~b  jumlah~6_udb  ke~7_hoh_udb  ijazah~m_udb  max_de~5_udb
percen~m_udb  atap8_udb     bb_masak_m~b  sta_pkh_udb   jumlah~7_udb  ke~8_hoh_udb  kelas_~m_udb  max_de~6_udb
percen~e_udb  atap9_udb     fasbab1_udb   sta_pkh_m_~b  jumlah~8_udb  ke~9_hoh_udb  pendid~m_udb  max_de~7_udb
adabpnt_udb   atap10_udb    fasbab2_udb   sta_ja~k_udb  jumlah~9_udb  ij~1_hoh_udb  worked~m_udb  pregna~h_udb
adabpnt_m_~b  atap_m_udb    fasbab3_udb   sta_ja~m_udb  juml~0up_udb  ij~2_hoh_udb  juml~h_m_udb  disabi~h_udb
sta_ba~1_udb  sumbe~m1_udb  fasbab4_udb   ada_le~s_udb  juml~t_m_udb  ij~3_hoh_udb  sta_ka~m_udb  chroni~h_udb
sta_ba~2_udb  sumbe~m2_udb  fasbab_m_udb  ada_le~m_udb  jumla~a1_udb  ij~4_hoh_udb  male_hoh_m~b  in_sch~h_udb
sta_ba~3_udb  sumbe~m3_udb  kloset1_udb   ada_pe~s_udb  jumla~a2_udb  ij~5_hoh_udb  age_hoh_m_~b  work_hh_udb
sta_ba~4_udb  sumber~4_udb  kloset2_udb   ad~nas_m_udb  jumla~a3_udb  ij~6_hoh_udb  num_in~1_udb  pregna~m_udb
sta_ba~5_udb  sumber~5_udb  kloset3_udb   ada_tv_udb    jum~a4up_udb  ij~7_hoh_udb  num_in_hh2~b  disabi~m_udb
sta_ba~m_udb  sumber~6_udb  kloset4_udb   ada_tv_m_udb  jum~ga_m_udb  worked~h_udb  num_in_hh3~b  chroni~m_udb
sta_lahan1~b  sumber~7_udb  kloset5_udb   ada_la~p_udb  luas_l~i_udb  l~a1_hoh_udb  num_in_hh4~b  in_sch~m_udb
sta_lahan2~b  sumber~8_udb  kloset_m_udb  ada_la~m_udb  luas_l~m_udb  l~a2_hoh_udb  num_in_hh5~b  work_hh_m_~b
sta_lahan3~b  sumber~9_udb  buang_~1_udb  ada_mo~r_udb  jumlah~0_udb  l~a3_hoh_udb  num_in_hh6~b  max_ed~m_udb
sta_lahan4~b  sumber~0_udb  buang_~2_udb  ada_motor_m~  jumla~r1_udb  l~a4_hoh_udb  num_in_hh7~b  max_gr~m_udb
sta_lahan5~b  sumbe~11_udb  buang_~3_udb  ada_m~il_udb  jumla~r2_udb  l~a5_hoh_udb  num_in_hh8~b  max_de~m_udb
sta_lahan_~b  sumbe~12_udb  buang_~4_udb  ada~il_m_udb  jumla~r3_udb  l~a6_hoh_udb  num_in_hh9~b  num_in_hh_~b

. 
. save "$cleaned/sep_2018_udb_lasso_pool.dta", replace
file /Users/clotairemit.edu/Dropbox (MIT)/J-PAL Raskin Transition/10_Analysis&Results/Agent Experiment
    Analysis/01_Data/cleaned/sep_2018_udb_lasso_pool.dta saved

. di c(k)
336

. // 336 vars
. 
. /*----------------------------------------------------*/
.         /* Section 3: Clean Mar 19 UDB Merge */
. /*----------------------------------------------------*/
. 
. u "$udb_mar19/SSN_BDT_KOR1903_RT_URUT_FULL.dta", clear

. count if idbdt != ""
  111,671

. di _N
315672

. // NOTE: 111,671 / 315,672 HHs are matched
. // Individual dataset has village and kec codes
. drop r101-exp_cap

. ds
renum         jumlah_kel~a  jumlah_kamar  kloset        ada_laptop    luas_atb      sta_kip       percentile
idbdt         sta_bangunan  sumber_air~m  buang_tinja   ada_sepeda    rumah_lain    sta_kis       id_pengurus
adapkh        sta_lahan     nomor_mete~r  ada_tabung~s  ada_motor     jumlah_sapi   sta_bpjs_m~i  flag_ada_~15
adakks2016    luas_lantai   cara_perol~m  ada_lemari~s  ada_mobil     jumlah_ker~u  sta_jamsos~k  match_rt
adakks2017    lantai        sumber_pen~n  ada_ac        ada_perahu    jumlah_kuda   sta_asuransi
adapbi        dinding       daya          ada_pemanas   ada_motor_~l  jumlah_babi   sta_pkh
adadapodik    kondisi_di~g  bb_masak      ada_telepon   ada_perahu~r  jumlah_kam~g  sta_rastra
adabpnt       atap          nomor_gas     ada_tv        ada_kapal     sta_art_us~a  sta_kur
jumlah_art    kondisi_atap  fasbab        ada_emas      aset_tak_b~k  sta_kks       sta_kebera~t

. 
. // get kec and village codes from individual dataset
. preserve

. u "$udb_mar19/SSN_BDT_KOR1903_ID_FULL.dta", clear

. count if r103 == .
  0

. count if r104 == .
  0

. summ renum

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       renum |  1,204,466      160396    93116.96          1     315672

. duplicates drop renum, force

Duplicates in terms of renum

(888,794 observations deleted)

. di _N
315672

. keep renum r103 r104

. tempfile kec_vil_codes

. save `kec_vil_codes'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.000007 saved as .dta format

. restore

. 
. // merge in kec and village codes
. merge 1:1 renum using `kec_vil_codes', assert(3)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                           315,672  (_merge==3)
    -----------------------------------------

. drop _m

. 
. quietly ds

. di "`r(varlist)'"
renum idbdt adapkh adakks2016 adakks2017 adapbi adadapodik adabpnt jumlah_art jumlah_keluarga sta_bangunan sta_lahan luas_l
> antai lantai dinding kondisi_dinding atap kondisi_atap jumlah_kamar sumber_airminum nomor_meter_air cara_peroleh_airminum
>  sumber_penerangan daya bb_masak nomor_gas fasbab kloset buang_tinja ada_tabung_gas ada_lemari_es ada_ac ada_pemanas ada_
> telepon ada_tv ada_emas ada_laptop ada_sepeda ada_motor ada_mobil ada_perahu ada_motor_tempel ada_perahu_motor ada_kapal 
> aset_tak_bergerak luas_atb rumah_lain jumlah_sapi jumlah_kerbau jumlah_kuda jumlah_babi jumlah_kambing sta_art_usaha sta_
> kks sta_kip sta_kis sta_bpjs_mandiri sta_jamsostek sta_asuransi sta_pkh sta_rastra sta_kur sta_keberadaan_rt percentile i
> d_pengurus flag_ada_di_pbdt15 match_rt r103 r104

. 
. 
. // Variable: In UDB dummy
. tab match_rt

   match_rt |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    204,001       64.62       64.62
          1 |    111,671       35.38      100.00
------------+-----------------------------------
      Total |    315,672      100.00

. gen udb = match_rt == 1

. tab udb

        udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    204,001       64.62       64.62
          1 |    111,671       35.38      100.00
------------+-----------------------------------
      Total |    315,672      100.00

. 
. // NOTE: This var is not found in survey, I assume it is a 0/1 variable so I recode other values to .
. // sta_keberadaan_rt: Existence of HH members outside the household
. tab sta_keberadaan_rt

 Keberadaan |
 ART diluar |
      Rumah |
     Tangga |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        307        2.74        2.74
          1 |     10,614       94.89       97.64
          4 |        212        1.90       99.54
          6 |         52        0.46      100.00
------------+-----------------------------------
      Total |     11,185      100.00

. recode sta_keberadaan_rt (4 6 = .)
(264 changes made to sta_keberadaan_rt)

. 
. *** Set missing to 0, create missing indicator
. foreach var of varlist adapkh adakks2016 adakks2017 adapbi adadapodik sta_keberadaan_rt flag_ada_di_pbdt15 jumlah_sapi ju
> mlah_kerbau jumlah_kuda jumlah_babi jumlah_kambing percentile {
  2.   tab `var'
  3.   // create dummy if var missing
.   gen `var'_m_udb = `var' == .
  4. 
.   // create copy of var where . is set to 0
.   recode `var' (. = 0), gen(`var'_udb)
  5. 
.   tab `var'_udb `var'_m_udb
  6. }

Kepesertaan |
        PKH |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     64,700       58.31       58.31
          1 |     46,253       41.69      100.00
------------+-----------------------------------
      Total |    110,953      100.00
(204,719 differences between adapkh and adapkh_udb)

 RECODE of |
    adapkh |
(Kepeserta |     adapkh_m_udb
   an PKH) |         0          1 |     Total
-----------+----------------------+----------
         0 |    64,700    204,719 |   269,419 
         1 |    46,253          0 |    46,253 
-----------+----------------------+----------
     Total |   110,953    204,719 |   315,672 

Kepemilikan |
   KKS 2016 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     65,214       59.81       59.81
          1 |     43,829       40.19      100.00
------------+-----------------------------------
      Total |    109,043      100.00
(206,629 differences between adakks2016 and adakks2016_udb)

 RECODE of |
adakks2016 |
(Kepemilik |
    an KKS |   adakks2016_m_udb
     2016) |         0          1 |     Total
-----------+----------------------+----------
         0 |    65,214    206,629 |   271,843 
         1 |    43,829          0 |    43,829 
-----------+----------------------+----------
     Total |   109,043    206,629 |   315,672 

Kepemilikan |
   KKS 2017 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     43,826       39.54       39.54
          1 |     67,003       60.46      100.00
------------+-----------------------------------
      Total |    110,829      100.00
(204,843 differences between adakks2017 and adakks2017_udb)

 RECODE of |
adakks2017 |
(Kepemilik |
    an KKS |   adakks2017_m_udb
     2017) |         0          1 |     Total
-----------+----------------------+----------
         0 |    43,826    204,843 |   248,669 
         1 |    67,003          0 |    67,003 
-----------+----------------------+----------
     Total |   110,829    204,843 |   315,672 

Kepesertaan |
        PBI |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     49,698       45.31       45.31
          1 |     59,983       54.69      100.00
------------+-----------------------------------
      Total |    109,681      100.00
(205,991 differences between adapbi and adapbi_udb)

 RECODE of |
    adapbi |
(Kepeserta |     adapbi_m_udb
   an PBI) |         0          1 |     Total
-----------+----------------------+----------
         0 |    49,698    205,991 |   255,689 
         1 |    59,983          0 |    59,983 
-----------+----------------------+----------
     Total |   109,681    205,991 |   315,672 

 Keberadaan |
      dalam |
    Dapodik |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     59,054       54.16       54.16
          1 |     49,989       45.84      100.00
------------+-----------------------------------
      Total |    109,043      100.00
(206,629 differences between adadapodik and adadapodik_udb)

 RECODE of |
adadapodik |
(Keberadaa |
   n dalam |   adadapodik_m_udb
  Dapodik) |         0          1 |     Total
-----------+----------------------+----------
         0 |    59,054    206,629 |   265,683 
         1 |    49,989          0 |    49,989 
-----------+----------------------+----------
     Total |   109,043    206,629 |   315,672 

 Keberadaan |
 ART diluar |
      Rumah |
     Tangga |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        307        2.81        2.81
          1 |     10,614       97.19      100.00
------------+-----------------------------------
      Total |     10,921      100.00
(304,751 differences between sta_keberadaan_rt and sta_keberadaan_rt_udb)

 RECODE of |
sta_kebera |
   daan_rt |
(Keberadaa |
     n ART |
    diluar | sta_keberadaan_rt_m_u
     Rumah |          db
   Tangga) |         0          1 |     Total
-----------+----------------------+----------
         0 |       307    304,751 |   305,058 
         1 |    10,614          0 |    10,614 
-----------+----------------------+----------
     Total |    10,921    304,751 |   315,672 

 Keterangan |
 Keberadaan |
   BDT 2015 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      4,487        4.02        4.02
          1 |    107,184       95.98      100.00
------------+-----------------------------------
      Total |    111,671      100.00
(204,001 differences between flag_ada_di_pbdt15 and flag_ada_di_pbdt15_udb)

 RECODE of |
flag_ada_d |
  i_pbdt15 |
(Keteranga |
         n | flag_ada_di_pbdt15_m_
Keberadaan |          udb
 BDT 2015) |         0          1 |     Total
-----------+----------------------+----------
         0 |     4,487    204,001 |   208,488 
         1 |   107,184          0 |   107,184 
-----------+----------------------+----------
     Total |   111,671    204,001 |   315,672 

5.4a Jumlah |
       Sapi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     28,475       79.90       79.90
          1 |      3,385        9.50       89.40
          2 |      2,266        6.36       95.76
          3 |        708        1.99       97.75
          4 |        383        1.07       98.82
          5 |        180        0.51       99.33
          6 |         88        0.25       99.57
          7 |         30        0.08       99.66
          8 |         29        0.08       99.74
          9 |         15        0.04       99.78
         10 |         25        0.07       99.85
         11 |          5        0.01       99.87
         12 |         19        0.05       99.92
         13 |          7        0.02       99.94
         14 |          1        0.00       99.94
         15 |          9        0.03       99.97
         16 |          1        0.00       99.97
         18 |          1        0.00       99.97
         19 |          1        0.00       99.97
         20 |          5        0.01       99.99
         21 |          1        0.00       99.99
         22 |          1        0.00       99.99
         23 |          1        0.00      100.00
         75 |          1        0.00      100.00
------------+-----------------------------------
      Total |     35,637      100.00
(280,035 differences between jumlah_sapi and jumlah_sapi_udb)

 RECODE of |
jumlah_sap |
   i (5.4a |
    Jumlah |   jumlah_sapi_m_udb
     Sapi) |         0          1 |     Total
-----------+----------------------+----------
         0 |    28,475    280,035 |   308,510 
         1 |     3,385          0 |     3,385 
         2 |     2,266          0 |     2,266 
         3 |       708          0 |       708 
         4 |       383          0 |       383 
         5 |       180          0 |       180 
         6 |        88          0 |        88 
         7 |        30          0 |        30 
         8 |        29          0 |        29 
         9 |        15          0 |        15 
        10 |        25          0 |        25 
        11 |         5          0 |         5 
        12 |        19          0 |        19 
        13 |         7          0 |         7 
        14 |         1          0 |         1 
        15 |         9          0 |         9 
        16 |         1          0 |         1 
        18 |         1          0 |         1 
        19 |         1          0 |         1 
        20 |         5          0 |         5 
        21 |         1          0 |         1 
        22 |         1          0 |         1 
        23 |         1          0 |         1 
        75 |         1          0 |         1 
-----------+----------------------+----------
     Total |    35,637    280,035 |   315,672 

5.4b Jumlah |
     Kerbau |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     30,311       97.43       97.43
          1 |        369        1.19       98.61
          2 |        226        0.73       99.34
          3 |         80        0.26       99.60
          4 |         44        0.14       99.74
          5 |         27        0.09       99.83
          6 |         15        0.05       99.87
          7 |          2        0.01       99.88
          8 |          6        0.02       99.90
          9 |          3        0.01       99.91
         10 |          8        0.03       99.94
         11 |          1        0.00       99.94
         12 |          6        0.02       99.96
         13 |          2        0.01       99.96
         14 |          2        0.01       99.97
         15 |          3        0.01       99.98
         17 |          1        0.00       99.98
         18 |          1        0.00       99.99
         19 |          1        0.00       99.99
         20 |          1        0.00       99.99
         23 |          1        0.00      100.00
        127 |          1        0.00      100.00
------------+-----------------------------------
      Total |     31,111      100.00
(284,561 differences between jumlah_kerbau and jumlah_kerbau_udb)

 RECODE of |
jumlah_ker |
 bau (5.4b |
    Jumlah |  jumlah_kerbau_m_udb
   Kerbau) |         0          1 |     Total
-----------+----------------------+----------
         0 |    30,311    284,561 |   314,872 
         1 |       369          0 |       369 
         2 |       226          0 |       226 
         3 |        80          0 |        80 
         4 |        44          0 |        44 
         5 |        27          0 |        27 
         6 |        15          0 |        15 
         7 |         2          0 |         2 
         8 |         6          0 |         6 
         9 |         3          0 |         3 
        10 |         8          0 |         8 
        11 |         1          0 |         1 
        12 |         6          0 |         6 
        13 |         2          0 |         2 
        14 |         2          0 |         2 
        15 |         3          0 |         3 
        17 |         1          0 |         1 
        18 |         1          0 |         1 
        19 |         1          0 |         1 
        20 |         1          0 |         1 
        23 |         1          0 |         1 
       127 |         1          0 |         1 
-----------+----------------------+----------
     Total |    31,111    284,561 |   315,672 

5.4c Jumlah |
       Kuda |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     30,507       98.78       98.78
          1 |        225        0.73       99.50
          2 |         87        0.28       99.79
          3 |         23        0.07       99.86
          4 |         25        0.08       99.94
          5 |          4        0.01       99.95
          6 |          4        0.01       99.97
          7 |          4        0.01       99.98
          8 |          1        0.00       99.98
         10 |          3        0.01       99.99
         11 |          1        0.00      100.00
         12 |          1        0.00      100.00
------------+-----------------------------------
      Total |     30,885      100.00
(284,787 differences between jumlah_kuda and jumlah_kuda_udb)

 RECODE of |
jumlah_kud |
   a (5.4c |
    Jumlah |   jumlah_kuda_m_udb
     Kuda) |         0          1 |     Total
-----------+----------------------+----------
         0 |    30,507    284,787 |   315,294 
         1 |       225          0 |       225 
         2 |        87          0 |        87 
         3 |        23          0 |        23 
         4 |        25          0 |        25 
         5 |         4          0 |         4 
         6 |         4          0 |         4 
         7 |         4          0 |         4 
         8 |         1          0 |         1 
        10 |         3          0 |         3 
        11 |         1          0 |         1 
        12 |         1          0 |         1 
-----------+----------------------+----------
     Total |    30,885    284,787 |   315,672 

5.4d Jumlah |
       Babi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     27,926       79.25       79.25
          1 |      3,431        9.74       88.98
          2 |      2,241        6.36       95.34
          3 |        715        2.03       97.37
          4 |        448        1.27       98.64
          5 |        208        0.59       99.23
          6 |         98        0.28       99.51
          7 |         44        0.12       99.64
          8 |         40        0.11       99.75
          9 |         17        0.05       99.80
         10 |         28        0.08       99.88
         11 |          6        0.02       99.90
         12 |         19        0.05       99.95
         13 |          1        0.00       99.95
         14 |          1        0.00       99.95
         15 |          6        0.02       99.97
         16 |          2        0.01       99.98
         18 |          2        0.01       99.98
         19 |          1        0.00       99.99
         20 |          5        0.01      100.00
------------+-----------------------------------
      Total |     35,239      100.00
(280,433 differences between jumlah_babi and jumlah_babi_udb)

 RECODE of |
jumlah_bab |
   i (5.4d |
    Jumlah |   jumlah_babi_m_udb
     Babi) |         0          1 |     Total
-----------+----------------------+----------
         0 |    27,926    280,433 |   308,359 
         1 |     3,431          0 |     3,431 
         2 |     2,241          0 |     2,241 
         3 |       715          0 |       715 
         4 |       448          0 |       448 
         5 |       208          0 |       208 
         6 |        98          0 |        98 
         7 |        44          0 |        44 
         8 |        40          0 |        40 
         9 |        17          0 |        17 
        10 |        28          0 |        28 
        11 |         6          0 |         6 
        12 |        19          0 |        19 
        13 |         1          0 |         1 
        14 |         1          0 |         1 
        15 |         6          0 |         6 
        16 |         2          0 |         2 
        18 |         2          0 |         2 
        19 |         1          0 |         1 
        20 |         5          0 |         5 
-----------+----------------------+----------
     Total |    35,239    280,433 |   315,672 

5.4e Jumlah |
Kambing/Dom |
         ba |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     28,783       81.80       81.80
          1 |      1,263        3.59       85.38
          2 |      2,053        5.83       91.22
          3 |      1,154        3.28       94.50
          4 |        776        2.21       96.70
          5 |        479        1.36       98.06
          6 |        243        0.69       98.76
          7 |        120        0.34       99.10
          8 |         96        0.27       99.37
          9 |         34        0.10       99.47
         10 |         85        0.24       99.71
         11 |         15        0.04       99.75
         12 |         30        0.09       99.84
         13 |         13        0.04       99.87
         14 |          5        0.01       99.89
         15 |         20        0.06       99.94
         16 |          6        0.02       99.96
         17 |          2        0.01       99.97
         19 |          1        0.00       99.97
         20 |         10        0.03      100.00
         37 |          1        0.00      100.00
------------+-----------------------------------
      Total |     35,189      100.00
(280,483 differences between jumlah_kambing and jumlah_kambing_udb)

 RECODE of |
jumlah_kam |
bing (5.4e |
    Jumlah |
Kambing/Do | jumlah_kambing_m_udb
      mba) |         0          1 |     Total
-----------+----------------------+----------
         0 |    28,783    280,483 |   309,266 
         1 |     1,263          0 |     1,263 
         2 |     2,053          0 |     2,053 
         3 |     1,154          0 |     1,154 
         4 |       776          0 |       776 
         5 |       479          0 |       479 
         6 |       243          0 |       243 
         7 |       120          0 |       120 
         8 |        96          0 |        96 
         9 |        34          0 |        34 
        10 |        85          0 |        85 
        11 |        15          0 |        15 
        12 |        30          0 |        30 
        13 |        13          0 |        13 
        14 |         5          0 |         5 
        15 |        20          0 |        20 
        16 |         6          0 |         6 
        17 |         2          0 |         2 
        19 |         1          0 |         1 
        20 |        10          0 |        10 
        37 |         1          0 |         1 
-----------+----------------------+----------
     Total |    35,189    280,483 |   315,672 

  Persentil |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      2,945        2.69        2.69
          2 |      3,009        2.74        5.43
          3 |      2,759        2.52        7.95
          4 |      2,737        2.50       10.44
          5 |      2,634        2.40       12.85
          6 |      2,679        2.44       15.29
          7 |      2,705        2.47       17.76
          8 |      2,543        2.32       20.08
          9 |      2,417        2.20       22.28
         10 |      2,430        2.22       24.50
         11 |      2,569        2.34       26.84
         12 |      2,487        2.27       29.11
         13 |      2,403        2.19       31.30
         14 |      2,431        2.22       33.52
         15 |      2,370        2.16       35.68
         16 |      2,437        2.22       37.90
         17 |      2,505        2.28       40.19
         18 |      2,418        2.21       42.39
         19 |      2,281        2.08       44.47
         20 |      2,379        2.17       46.64
         21 |      2,268        2.07       48.71
         22 |      2,330        2.13       50.84
         23 |      2,215        2.02       52.86
         24 |      2,178        1.99       54.84
         25 |      2,262        2.06       56.91
         26 |      2,348        2.14       59.05
         27 |      2,131        1.94       60.99
         28 |      2,197        2.00       63.00
         29 |      2,264        2.07       65.06
         30 |      2,160        1.97       67.03
         31 |      2,126        1.94       68.97
         32 |      2,120        1.93       70.90
         33 |      2,017        1.84       72.74
         34 |      1,848        1.69       74.43
         35 |      1,244        1.13       75.56
         36 |      1,205        1.10       76.66
         37 |      1,199        1.09       77.76
         38 |      1,063        0.97       78.73
         39 |      1,087        0.99       79.72
         40 |        996        0.91       80.63
         41 |      1,061        0.97       81.59
         42 |        923        0.84       82.44
         43 |      1,021        0.93       83.37
         44 |        976        0.89       84.26
         45 |        881        0.80       85.06
         46 |        904        0.82       85.89
         47 |        815        0.74       86.63
         48 |        877        0.80       87.43
         49 |        746        0.68       88.11
         50 |        857        0.78       88.89
         51 |        767        0.70       89.59
         52 |        737        0.67       90.26
         53 |        758        0.69       90.95
         54 |        693        0.63       91.59
         55 |        665        0.61       92.19
         56 |        590        0.54       92.73
         57 |        599        0.55       93.28
         58 |        603        0.55       93.83
         59 |        563        0.51       94.34
         60 |        560        0.51       94.85
         61 |        544        0.50       95.35
         62 |        529        0.48       95.83
         63 |        451        0.41       96.24
         64 |        492        0.45       96.69
         65 |        425        0.39       97.08
         66 |        408        0.37       97.45
         67 |        399        0.36       97.81
         68 |        337        0.31       98.12
         69 |        313        0.29       98.41
         70 |        311        0.28       98.69
         71 |        255        0.23       98.92
         72 |        209        0.19       99.11
         73 |        188        0.17       99.29
         74 |        200        0.18       99.47
         75 |        282        0.26       99.73
         76 |         67        0.06       99.79
         77 |         12        0.01       99.80
         78 |          7        0.01       99.80
         79 |          4        0.00       99.81
         80 |          4        0.00       99.81
         81 |          2        0.00       99.81
         82 |          8        0.01       99.82
         83 |          7        0.01       99.83
         84 |          1        0.00       99.83
         86 |          7        0.01       99.83
         87 |          3        0.00       99.84
         89 |          2        0.00       99.84
         92 |          1        0.00       99.84
         94 |          1        0.00       99.84
         95 |          4        0.00       99.84
         96 |          2        0.00       99.85
         98 |          2        0.00       99.85
         99 |          1        0.00       99.85
        100 |        166        0.15      100.00
------------+-----------------------------------
      Total |    109,636      100.00
(206,036 differences between percentile and percentile_udb)

 RECODE of |
percentile |
(Persentil |   percentile_m_udb
         ) |         0          1 |     Total
-----------+----------------------+----------
         0 |         0    206,036 |   206,036 
         1 |     2,945          0 |     2,945 
         2 |     3,009          0 |     3,009 
         3 |     2,759          0 |     2,759 
         4 |     2,737          0 |     2,737 
         5 |     2,634          0 |     2,634 
         6 |     2,679          0 |     2,679 
         7 |     2,705          0 |     2,705 
         8 |     2,543          0 |     2,543 
         9 |     2,417          0 |     2,417 
        10 |     2,430          0 |     2,430 
        11 |     2,569          0 |     2,569 
        12 |     2,487          0 |     2,487 
        13 |     2,403          0 |     2,403 
        14 |     2,431          0 |     2,431 
        15 |     2,370          0 |     2,370 
        16 |     2,437          0 |     2,437 
        17 |     2,505          0 |     2,505 
        18 |     2,418          0 |     2,418 
        19 |     2,281          0 |     2,281 
        20 |     2,379          0 |     2,379 
        21 |     2,268          0 |     2,268 
        22 |     2,330          0 |     2,330 
        23 |     2,215          0 |     2,215 
        24 |     2,178          0 |     2,178 
        25 |     2,262          0 |     2,262 
        26 |     2,348          0 |     2,348 
        27 |     2,131          0 |     2,131 
        28 |     2,197          0 |     2,197 
        29 |     2,264          0 |     2,264 
        30 |     2,160          0 |     2,160 
        31 |     2,126          0 |     2,126 
        32 |     2,120          0 |     2,120 
        33 |     2,017          0 |     2,017 
        34 |     1,848          0 |     1,848 
        35 |     1,244          0 |     1,244 
        36 |     1,205          0 |     1,205 
        37 |     1,199          0 |     1,199 
        38 |     1,063          0 |     1,063 
        39 |     1,087          0 |     1,087 
        40 |       996          0 |       996 
        41 |     1,061          0 |     1,061 
        42 |       923          0 |       923 
        43 |     1,021          0 |     1,021 
        44 |       976          0 |       976 
        45 |       881          0 |       881 
        46 |       904          0 |       904 
        47 |       815          0 |       815 
        48 |       877          0 |       877 
        49 |       746          0 |       746 
        50 |       857          0 |       857 
        51 |       767          0 |       767 
        52 |       737          0 |       737 
        53 |       758          0 |       758 
        54 |       693          0 |       693 
        55 |       665          0 |       665 
        56 |       590          0 |       590 
        57 |       599          0 |       599 
        58 |       603          0 |       603 
        59 |       563          0 |       563 
        60 |       560          0 |       560 
        61 |       544          0 |       544 
        62 |       529          0 |       529 
        63 |       451          0 |       451 
        64 |       492          0 |       492 
        65 |       425          0 |       425 
        66 |       408          0 |       408 
        67 |       399          0 |       399 
        68 |       337          0 |       337 
        69 |       313          0 |       313 
        70 |       311          0 |       311 
        71 |       255          0 |       255 
        72 |       209          0 |       209 
        73 |       188          0 |       188 
        74 |       200          0 |       200 
        75 |       282          0 |       282 
        76 |        67          0 |        67 
        77 |        12          0 |        12 
        78 |         7          0 |         7 
        79 |         4          0 |         4 
        80 |         4          0 |         4 
        81 |         2          0 |         2 
        82 |         8          0 |         8 
        83 |         7          0 |         7 
        84 |         1          0 |         1 
        86 |         7          0 |         7 
        87 |         3          0 |         3 
        89 |         2          0 |         2 
        92 |         1          0 |         1 
        94 |         1          0 |         1 
        95 |         4          0 |         4 
        96 |         2          0 |         2 
        98 |         2          0 |         2 
        99 |         1          0 |         1 
       100 |       166          0 |       166 
-----------+----------------------+----------
     Total |   109,636    206,036 |   315,672 

. 
. ** BPNT eligibility var
. // NOTE: adabpnt has no 0 for ineligible UDB HHs; I assume all UDB HHs that are missing are 0s
. tab adabpnt

Kepesertaan |
       BPNT |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      3,735      100.00      100.00
------------+-----------------------------------
      Total |      3,735      100.00

. 
. // replace missing with 0s
. recode adabpnt (. = 0), gen(adabpnt_udb)
(311,937 differences between adabpnt and adabpnt_udb)

. 
. // then create missing var
. gen adabpnt_m_udb = adabpnt_udb == 0 & udb == 0

. tab adabpnt_udb adabpnt_m_udb

 RECODE of |
   adabpnt |
(Kepeserta |     adabpnt_m_udb
  an BPNT) |         0          1 |     Total
-----------+----------------------+----------
         0 |   107,936    204,001 |   311,937 
         1 |     3,735          0 |     3,735 
-----------+----------------------+----------
     Total |   111,671    204,001 |   315,672 

. 
. // rename to shorten
. rename cara_peroleh_airminum caraperolehairmin

. rename sumber_penerangan sumberpen

. 
. // create dummies categories of categorical vars (plus missing)
. foreach var of varlist sta_bangunan sta_lahan lantai dinding atap sumber_airminum caraperolehairmin sumberpen daya bb_mas
> ak fasbab kloset buang_tinja {
  2.   // create indicators for each category
.   tab `var', gen(`var')
  3. 
.   // set missing in each indicator to 0
.   foreach dummy of varlist `var'?* {
  4.     recode `dummy' (. = 0)
  5.     rename `dummy' `dummy'_udb
  6.   }
  7. 
.   // create missing indicator
.   gen `var'_m_udb = `var' == .
  8. 
.   // test that all dummies are exhaustive and mutually exclusive
.   gen test = 0
  9.   foreach testvar of varlist `var'*udb {
 10.     quietly replace test = test + `testvar'
 11.   }
 12.   assert test == 1
 13.   drop test
 14. }

1.a. Status |
Kepemilikan |
   Bangunan |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |     95,874       86.76       86.76
          2 |      3,464        3.13       89.89
          3 |      9,740        8.81       98.71
          4 |        241        0.22       98.93
          5 |      1,186        1.07      100.00
------------+-----------------------------------
      Total |    110,506      100.00
(205,166 changes made to sta_bangunan1)
(205,166 changes made to sta_bangunan2)
(205,166 changes made to sta_bangunan3)
(205,166 changes made to sta_bangunan4)
(205,166 changes made to sta_bangunan5)
(205,166 changes made to sta_bangunan6)

1.b. Status |
      lahan |
     tempat |
    tinggal |
       yang |
 ditempati: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        344        0.35        0.35
          1 |     85,415       87.30       87.65
          2 |      7,809        7.98       95.63
          3 |      1,694        1.73       97.37
          4 |      2,578        2.63      100.00
------------+-----------------------------------
      Total |     97,840      100.00
(217,832 changes made to sta_lahan1)
(217,832 changes made to sta_lahan2)
(217,832 changes made to sta_lahan3)
(217,832 changes made to sta_lahan4)
(217,832 changes made to sta_lahan5)

   3. Jenis |
     lantai |
   terluas: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |        197        0.18        0.18
          2 |     16,206       14.67       14.84
          3 |        121        0.11       14.95
          4 |      5,701        5.16       20.11
          5 |      4,070        3.68       23.80
          6 |     48,980       44.32       68.12
          7 |      1,869        1.69       69.81
          8 |     18,644       16.87       86.68
          9 |     14,387       13.02       99.70
         10 |        332        0.30      100.00
------------+-----------------------------------
      Total |    110,508      100.00
(205,164 changes made to lantai1)
(205,164 changes made to lantai2)
(205,164 changes made to lantai3)
(205,164 changes made to lantai4)
(205,164 changes made to lantai5)
(205,164 changes made to lantai6)
(205,164 changes made to lantai7)
(205,164 changes made to lantai8)
(205,164 changes made to lantai9)
(205,164 changes made to lantai10)
(205,164 changes made to lantai11)

 4.a. Jenis |
    dinding |
   terluas: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |     52,448       47.46       47.46
          2 |      1,965        1.78       49.24
          3 |     40,968       37.07       86.31
          4 |      8,470        7.66       93.98
          5 |        224        0.20       94.18
          6 |      2,841        2.57       96.75
          7 |      3,591        3.25      100.00
------------+-----------------------------------
      Total |    110,508      100.00
(205,164 changes made to dinding1)
(205,164 changes made to dinding2)
(205,164 changes made to dinding3)
(205,164 changes made to dinding4)
(205,164 changes made to dinding5)
(205,164 changes made to dinding6)
(205,164 changes made to dinding7)
(205,164 changes made to dinding8)

 5.a. Jenis |
       atap |
   terluas: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |        472        0.43        0.43
          2 |        244        0.22        0.65
          3 |        438        0.40        1.05
          4 |     40,627       36.76       37.81
          5 |      6,551        5.93       43.74
          6 |     55,054       49.82       93.56
          7 |        791        0.72       94.27
          8 |        106        0.10       94.37
          9 |      6,071        5.49       99.86
         10 |        153        0.14      100.00
------------+-----------------------------------
      Total |    110,508      100.00
(205,164 changes made to atap1)
(205,164 changes made to atap2)
(205,164 changes made to atap3)
(205,164 changes made to atap4)
(205,164 changes made to atap5)
(205,164 changes made to atap6)
(205,164 changes made to atap7)
(205,164 changes made to atap8)
(205,164 changes made to atap9)
(205,164 changes made to atap10)
(205,164 changes made to atap11)

  7. Sumber |
 air minum: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |        415        0.38        0.38
          2 |      9,415        8.52        8.90
          3 |      9,801        8.87       17.77
          4 |      2,923        2.65       20.41
          5 |     12,574       11.38       31.79
          6 |     29,804       26.97       58.76
          7 |     14,406       13.04       71.79
          8 |     13,670       12.37       84.16
          9 |      7,006        6.34       90.50
         10 |      5,538        5.01       95.52
         11 |      4,638        4.20       99.71
         12 |        317        0.29      100.00
------------+-----------------------------------
      Total |    110,508      100.00
(205,164 changes made to sumber_airminum1)
(205,164 changes made to sumber_airminum2)
(205,164 changes made to sumber_airminum3)
(205,164 changes made to sumber_airminum4)
(205,164 changes made to sumber_airminum5)
(205,164 changes made to sumber_airminum6)
(205,164 changes made to sumber_airminum7)
(205,164 changes made to sumber_airminum8)
(205,164 changes made to sumber_airminum9)
(205,164 changes made to sumber_airminum10)
(205,164 changes made to sumber_airminum11)
(205,164 changes made to sumber_airminum12)
(205,164 changes made to sumber_airminum13)

    8. Cara |
 memperoleh |
 air minum: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |     14,017       12.68       12.69
          2 |     12,038       10.89       23.58
          3 |     84,451       76.42      100.00
------------+-----------------------------------
      Total |    110,507      100.00
(205,165 changes made to caraperolehairmin1)
(205,165 changes made to caraperolehairmin2)
(205,165 changes made to caraperolehairmin3)
(205,165 changes made to caraperolehairmin4)

9.a. Sumber |
 penerangan |
     utama: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          2        0.00        0.00
          1 |     96,669       87.48       87.48
          2 |      5,392        4.88       92.36
          3 |      8,445        7.64      100.00
------------+-----------------------------------
      Total |    110,508      100.00
(205,164 changes made to sumberpen1)
(205,164 changes made to sumberpen2)
(205,164 changes made to sumberpen3)
(205,164 changes made to sumberpen4)

  9.b. Jika |
       R.9a |
 berkode 1, |
       daya |
 terpasang: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,419        1.45        1.45
          1 |     56,680       57.74       59.19
          2 |     22,455       22.88       82.06
          3 |      2,359        2.40       84.47
          4 |        155        0.16       84.63
          5 |         26        0.03       84.65
          6 |     15,066       15.35      100.00
------------+-----------------------------------
      Total |     98,160      100.00
(217,512 changes made to daya1)
(217,512 changes made to daya2)
(217,512 changes made to daya3)
(217,512 changes made to daya4)
(217,512 changes made to daya5)
(217,512 changes made to daya6)
(217,512 changes made to daya7)

  10. Bahan |
bakar/energ |
    i utama |
      untuk |
   memasak: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |        488        0.44        0.44
          2 |      1,390        1.26        1.70
          3 |     46,115       41.73       43.43
          4 |        114        0.10       43.53
          5 |      4,626        4.19       47.72
          6 |         30        0.03       47.75
          7 |        548        0.50       48.24
          8 |     56,827       51.42       99.67
          9 |        368        0.33      100.00
------------+-----------------------------------
      Total |    110,507      100.00
(205,165 changes made to bb_masak1)
(205,165 changes made to bb_masak2)
(205,165 changes made to bb_masak3)
(205,165 changes made to bb_masak4)
(205,165 changes made to bb_masak5)
(205,165 changes made to bb_masak6)
(205,165 changes made to bb_masak7)
(205,165 changes made to bb_masak8)
(205,165 changes made to bb_masak9)
(205,165 changes made to bb_masak10)

      11.a. |
 Penggunaan |
  fasilitas |
     tempat |
  buang air |
     besar: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |     63,951       57.87       57.87
          2 |     13,254       11.99       69.86
          3 |      6,182        5.59       75.46
          4 |     27,120       24.54      100.00
------------+-----------------------------------
      Total |    110,508      100.00
(205,164 changes made to fasbab1)
(205,164 changes made to fasbab2)
(205,164 changes made to fasbab3)
(205,164 changes made to fasbab4)
(205,164 changes made to fasbab5)

11.b. Jenis |
    kloset: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,844        2.16        2.16
          1 |     62,145       72.74       74.90
          2 |      4,879        5.71       80.61
          3 |     14,583       17.07       97.68
          4 |      1,978        2.32      100.00
------------+-----------------------------------
      Total |     85,429      100.00
(230,243 changes made to kloset1)
(230,243 changes made to kloset2)
(230,243 changes made to kloset3)
(230,243 changes made to kloset4)
(230,243 changes made to kloset5)

 12. Tempat |
 pembuangan |
      akhir |
     tinja: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          1        0.00        0.00
          1 |     42,882       38.80       38.81
          2 |      2,789        2.52       41.33
          3 |     28,666       25.94       67.27
          4 |     24,505       22.17       89.44
          5 |      9,306        8.42       97.87
          6 |      2,359        2.13      100.00
------------+-----------------------------------
      Total |    110,508      100.00
(205,164 changes made to buang_tinja1)
(205,164 changes made to buang_tinja2)
(205,164 changes made to buang_tinja3)
(205,164 changes made to buang_tinja4)
(205,164 changes made to buang_tinja5)
(205,164 changes made to buang_tinja6)
(205,164 changes made to buang_tinja7)

. 
. 
. *** Clean 1 = 3 = yes; 2 = 4 = no variables
. * fix unexplained values (do not correspond to survey) in miscellaneous variables
. tab aset_tak_bergerak

       5.3a |
Kepemilikan |
      Lahan |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          2        0.00        0.00
          1 |     90,005       81.45       81.45
          2 |     20,493       18.55      100.00
          6 |          1        0.00      100.00
          7 |          1        0.00      100.00
         14 |          1        0.00      100.00
         19 |          1        0.00      100.00
------------+-----------------------------------
      Total |    110,504      100.00

. recode aset_tak_bergerak (19 14 7 6 = .)
(4 changes made to aset_tak_bergerak)

. 
. // I recode assuming all 1s and 3s are yes, and all 2s and 4s are no
. foreach var of varlist kondisi_dinding kondisi_atap ada_tabung_gas ada_ac ada_telepon ada_emas ada_sepeda ada_motor_tempe
> l sta_art_usaha ///
>   sta_kks sta_kis sta_pkh sta_jamsostek ada_lemari_es ada_pemanas ada_tv ada_laptop ada_motor ada_mobil ada_perahu ada_pe
> rahu_motor ///
>   ada_kapal sta_kip sta_bpjs_mandiri sta_asuransi sta_rastra aset_tak_bergerak rumah_lain sta_kur {
  2.     assert inlist(`var', ., 0, 1, 2, 3, 4)
  3. 
.     // NOTE: some vars have 0s when questionnaire indicates answers should only be 1, 2, 3, or 4; I treat 0 as missing
.     replace `var' = . if `var' == 0
  4. 
.     // recode so 3 => 1 = yes; 2=4 => 0 no
.     recode `var' (3 = 1) (4 2 = 0) (. = 0), gen (`var'_udb)
  5. 
.     // create missing dummy
.     gen `var'_m_udb = `var' == .
  6.     tab `var'_udb `var'_m_udb
  7.   }
(1,075 real changes made, 1,075 to missing)
(292,157 differences between kondisi_dinding and kondisi_dinding_udb)

 RECODE of |
kondisi_di |
     nding |
(4.b. Jika |
      R.4a |
berkode 1, |
 2 atau 3, |
   kondisi | kondisi_dinding_m_udb
  dinding) |         0          1 |     Total
-----------+----------------------+----------
         0 |    72,027    220,130 |   292,157 
         1 |    23,515          0 |    23,515 
-----------+----------------------+----------
     Total |    95,542    220,130 |   315,672 
(552 real changes made, 552 to missing)
(288,414 differences between kondisi_atap and kondisi_atap_udb)

 RECODE of |
kondisi_at |
  ap (5.b. |
 Jika R.5a |
berkode 1, |
  2, 3, 4, |
 5, 6 atau |
 7 kondisi |  kondisi_atap_m_udb
         a |         0          1 |     Total
-----------+----------------------+----------
         0 |    76,920    211,494 |   288,414 
         1 |    27,258          0 |    27,258 
-----------+----------------------+----------
     Total |   104,178    211,494 |   315,672 
(8 real changes made, 8 to missing)
(312,930 differences between ada_tabung_gas and ada_tabung_gas_udb)

 RECODE of |
ada_tabung |
 _gas (1a. |
Tabung gas |
    5,5 kg |
      atau | ada_tabung_gas_m_udb
    lebih) |         0          1 |     Total
-----------+----------------------+----------
         0 |   107,755    205,175 |   312,930 
         1 |     2,742          0 |     2,742 
-----------+----------------------+----------
     Total |   110,497    205,175 |   315,672 
(8 real changes made, 8 to missing)
(315,346 differences between ada_ac and ada_ac_udb)

 RECODE of |
    ada_ac |
    (5.1c. |
Kepemilika |     ada_ac_m_udb
     n AC) |         0          1 |     Total
-----------+----------------------+----------
         0 |   110,171    205,175 |   315,346 
         1 |       326          0 |       326 
-----------+----------------------+----------
     Total |   110,497    205,175 |   315,672 
(8 real changes made, 8 to missing)
(314,693 differences between ada_telepon and ada_telepon_udb)

 RECODE of |
ada_telepo |
   n (5.1e |
Kepemilika |
 n Telepon |   ada_telepon_m_udb
    Rumah) |         0          1 |     Total
-----------+----------------------+----------
         0 |   109,519    205,174 |   314,693 
         1 |       979          0 |       979 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(8 real changes made, 8 to missing)
(310,906 differences between ada_emas and ada_emas_udb)

 RECODE of |
  ada_emas |
     (5.1g |
Kepemilika |
  n Emas > |    ada_emas_m_udb
  10 gram) |         0          1 |     Total
-----------+----------------------+----------
         0 |   105,732    205,174 |   310,906 
         1 |     4,766          0 |     4,766 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(5 real changes made, 5 to missing)
(294,549 differences between ada_sepeda and ada_sepeda_udb)

 RECODE of |
ada_sepeda |
     (5.1i |
Kepemilika |   ada_sepeda_m_udb
 n Sepeda) |         0          1 |     Total
-----------+----------------------+----------
         0 |    89,378    205,171 |   294,549 
         1 |    21,123          0 |    21,123 
-----------+----------------------+----------
     Total |   110,501    205,171 |   315,672 
(8 real changes made, 8 to missing)
(314,449 differences between ada_motor_tempel and ada_motor_tempel_udb)

 RECODE of |
ada_motor_ |
    tempel |
     (5.1m |
Kepemilika | ada_motor_tempel_m_ud
   n Motor |           b
   Tempel) |         0          1 |     Total
-----------+----------------------+----------
         0 |   109,275    205,174 |   314,449 
         1 |     1,223          0 |     1,223 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(1,241 real changes made, 1,241 to missing)
(257,197 differences between sta_art_usaha and sta_art_usaha_udb)

 RECODE of |
sta_art_us |
aha (5.5a. |
Apakah ada |
  ART yang |
  memiliki |
     usaha |
sendiri/be |  sta_art_usaha_m_udb
      rsam |         0          1 |     Total
-----------+----------------------+----------
         0 |    50,777    206,420 |   257,197 
         1 |    58,475          0 |    58,475 
-----------+----------------------+----------
     Total |   109,252    206,420 |   315,672 
(12 real changes made, 12 to missing)
(269,085 differences between sta_kks and sta_kks_udb)

 RECODE of |
   sta_kks |
(6a Status |     sta_kks_m_udb
      KKS) |         0          1 |     Total
-----------+----------------------+----------
         0 |    63,896    205,189 |   269,085 
         1 |    46,587          0 |    46,587 
-----------+----------------------+----------
     Total |   110,483    205,189 |   315,672 
(4 real changes made, 4 to missing)
(253,418 differences between sta_kis and sta_kis_udb)

 RECODE of |
   sta_kis |
(6c Status |     sta_kis_m_udb
      KIS) |         0          1 |     Total
-----------+----------------------+----------
         0 |    48,238    205,180 |   253,418 
         1 |    62,254          0 |    62,254 
-----------+----------------------+----------
     Total |   110,492    205,180 |   315,672 
(7 real changes made, 7 to missing)
(307,041 differences between sta_pkh and sta_pkh_udb)

 RECODE of |
   sta_pkh |
(6g Status |     sta_pkh_m_udb
      PKH) |         0          1 |     Total
-----------+----------------------+----------
         0 |   101,855    205,183 |   307,038 
         1 |     8,634          0 |     8,634 
-----------+----------------------+----------
     Total |   110,489    205,183 |   315,672 
(8 real changes made, 8 to missing)
(313,800 differences between sta_jamsostek and sta_jamsostek_udb)

 RECODE of |
sta_jamsos |
   tek (6e |
    Status |
      BPJS |
Ketenagake |  sta_jamsostek_m_udb
    rjaan) |         0          1 |     Total
-----------+----------------------+----------
         0 |   108,614    205,185 |   313,799 
         1 |     1,873          0 |     1,873 
-----------+----------------------+----------
     Total |   110,487    205,185 |   315,672 
(6 real changes made, 6 to missing)
(315,668 differences between ada_lemari_es and ada_lemari_es_udb)

 RECODE of |
ada_lemari |
_es (5.1b. |
    Lemari |  ada_lemari_es_m_udb
Es/Kulkas) |         0          1 |     Total
-----------+----------------------+----------
         0 |    86,750    205,172 |   291,922 
         1 |    23,750          0 |    23,750 
-----------+----------------------+----------
     Total |   110,500    205,172 |   315,672 
(8 real changes made, 8 to missing)
(315,672 differences between ada_pemanas and ada_pemanas_udb)

 RECODE of |
ada_pemana |
  s (5.1d. |
Kepemilika |
 n Pemanas |   ada_pemanas_m_udb
      Air) |         0          1 |     Total
-----------+----------------------+----------
         0 |   109,868    205,174 |   315,042 
         1 |       630          0 |       630 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(6 real changes made, 6 to missing)
(315,651 differences between ada_tv and ada_tv_udb)

 RECODE of |
    ada_tv |
     (5.1f |
Kepemilika |
         n |     ada_tv_m_udb
 Televisi) |         0          1 |     Total
-----------+----------------------+----------
         0 |    34,049    205,172 |   239,221 
         1 |    76,451          0 |    76,451 
-----------+----------------------+----------
     Total |   110,500    205,172 |   315,672 
(8 real changes made, 8 to missing)
(315,671 differences between ada_laptop and ada_laptop_udb)

 RECODE of |
ada_laptop |
     (5.1h |
Kepemilika |   ada_laptop_m_udb
 n Laptop) |         0          1 |     Total
-----------+----------------------+----------
         0 |   108,201    205,174 |   313,375 
         1 |     2,297          0 |     2,297 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(4 real changes made, 4 to missing)
(315,661 differences between ada_motor and ada_motor_udb)

 RECODE of |
 ada_motor |
     (5.1j |
Kepemilika |
  n Sepeda |    ada_motor_m_udb
    Motor) |         0          1 |     Total
-----------+----------------------+----------
         0 |    54,245    205,170 |   259,415 
         1 |    56,257          0 |    56,257 
-----------+----------------------+----------
     Total |   110,502    205,170 |   315,672 
(8 real changes made, 8 to missing)
(314,659 differences between ada_mobil and ada_mobil_udb)

 RECODE of |
 ada_mobil |
     (5.1k |
Kepemilika |    ada_mobil_m_udb
  n Mobil) |         0          1 |     Total
-----------+----------------------+----------
         0 |   109,485    205,174 |   314,659 
         1 |     1,013          0 |     1,013 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(8 real changes made, 8 to missing)
(315,672 differences between ada_perahu and ada_perahu_udb)

 RECODE of |
ada_perahu |
     (5.1l |
Kepemilika |   ada_perahu_m_udb
 n Perahu) |         0          1 |     Total
-----------+----------------------+----------
         0 |   107,688    205,174 |   312,862 
         1 |     2,810          0 |     2,810 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(8 real changes made, 8 to missing)
(315,672 differences between ada_perahu_motor and ada_perahu_motor_udb)

 RECODE of |
ada_perahu |
    _motor |
     (5.1n |
Kepemilika | ada_perahu_motor_m_ud
  n Perahu |           b
    Motor) |         0          1 |     Total
-----------+----------------------+----------
         0 |   109,499    205,174 |   314,673 
         1 |       999          0 |       999 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(8 real changes made, 8 to missing)
(315,622 differences between ada_kapal and ada_kapal_udb)

 RECODE of |
 ada_kapal |
     (5.1o |
Kepemilika |    ada_kapal_m_udb
  n Kapal) |         0          1 |     Total
-----------+----------------------+----------
         0 |   110,448    205,174 |   315,622 
         1 |        50          0 |        50 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(12 real changes made, 12 to missing)
(315,671 differences between sta_kip and sta_kip_udb)

 RECODE of |
   sta_kip |
(6b Status |     sta_kip_m_udb
      KIP) |         0          1 |     Total
-----------+----------------------+----------
         0 |    96,688    205,189 |   301,877 
         1 |    13,795          0 |    13,795 
-----------+----------------------+----------
     Total |   110,483    205,189 |   315,672 
(21 real changes made, 21 to missing)
(315,664 differences between sta_bpjs_mandiri and sta_bpjs_mandiri_udb)

 RECODE of |
sta_bpjs_m |
andiri (6d |
    Status | sta_bpjs_mandiri_m_ud
      BPJS |           b
  Mandiri) |         0          1 |     Total
-----------+----------------------+----------
         0 |   108,190    205,198 |   313,388 
         1 |     2,284          0 |     2,284 
-----------+----------------------+----------
     Total |   110,474    205,198 |   315,672 
(8 real changes made, 8 to missing)
(315,665 differences between sta_asuransi and sta_asuransi_udb)

 RECODE of |
sta_asuran |
    si (6f |
    Status |  sta_asuransi_m_udb
 Asuransi) |         0          1 |     Total
-----------+----------------------+----------
         0 |   103,926    205,185 |   309,111 
         1 |     6,561          0 |     6,561 
-----------+----------------------+----------
     Total |   110,487    205,185 |   315,672 
(7 real changes made, 7 to missing)
(315,628 differences between sta_rastra and sta_rastra_udb)

 RECODE of |
sta_rastra |
(6h Status |   sta_rastra_m_udb
   Rastra) |         0          1 |     Total
-----------+----------------------+----------
         0 |    28,299    205,184 |   233,483 
         1 |    82,189          0 |    82,189 
-----------+----------------------+----------
     Total |   110,488    205,184 |   315,672 
(2 real changes made, 2 to missing)
(225,667 differences between aset_tak_bergerak and aset_tak_bergerak_udb)

 RECODE of |
aset_tak_b |
   ergerak |
     (5.3a | aset_tak_bergerak_m_u
Kepemilika |          db
  n Lahan) |         0          1 |     Total
-----------+----------------------+----------
         0 |    20,493    205,174 |   225,667 
         1 |    90,005          0 |    90,005 
-----------+----------------------+----------
     Total |   110,498    205,174 |   315,672 
(8 real changes made, 8 to missing)
(315,661 differences between rumah_lain and rumah_lain_udb)

 RECODE of |
rumah_lain |
     (5.3b |
Kepemilika |
   n Rumah |   rumah_lain_m_udb
     Lain) |         0          1 |     Total
-----------+----------------------+----------
         0 |   109,380    205,176 |   314,556 
         1 |     1,116          0 |     1,116 
-----------+----------------------+----------
     Total |   110,496    205,176 |   315,672 
(8 real changes made, 8 to missing)
(313,906 differences between sta_kur and sta_kur_udb)

 RECODE of |
   sta_kur |
(6i Status |     sta_kur_m_udb
      KUR) |         0          1 |     Total
-----------+----------------------+----------
         0 |   108,721    205,185 |   313,906 
         1 |     1,766          0 |     1,766 
-----------+----------------------+----------
     Total |   110,487    205,185 |   315,672 

. 
. /*
>    nomor_meter_air     nomor_gas
>        id_pengurus  match_rt r103 r104
> */
. 
. ** jumlah_art: number of HH members
. // create dummies, treating as categorical variable to allow it to enter flexibly (10+ combined)
. tab jumlah_art, gen(jumlah_art)

     Jumlah |
    Anggota |
      Rumah |
     Tangga |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      3,996        3.58        3.58
          2 |     12,501       11.19       14.77
          3 |     21,609       19.35       34.12
          4 |     27,928       25.01       59.13
          5 |     20,825       18.65       77.78
          6 |     12,165       10.89       88.67
          7 |      6,454        5.78       94.45
          8 |      3,122        2.80       97.25
          9 |      1,639        1.47       98.72
         10 |        905        0.81       99.53
         11 |        231        0.21       99.73
         12 |        111        0.10       99.83
         13 |         74        0.07       99.90
         14 |         47        0.04       99.94
         15 |         23        0.02       99.96
         16 |         11        0.01       99.97
         17 |         10        0.01       99.98
         18 |          5        0.00       99.99
         19 |          5        0.00       99.99
         20 |          2        0.00       99.99
         21 |          2        0.00       99.99
         22 |          1        0.00      100.00
         23 |          2        0.00      100.00
         24 |          2        0.00      100.00
         34 |          1        0.00      100.00
------------+-----------------------------------
      Total |    111,671      100.00

. 
. // Create indicator for 10+ category
. gen jumlah_art10up_udb = 10 <= jumlah_art & jumlah_art <= 34

. tab jumlah_art10up_udb

jumlah_art1 |
    0up_udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    314,240       99.55       99.55
          1 |      1,432        0.45      100.00
------------+-----------------------------------
      Total |    315,672      100.00

. 
. // set missings to 0
. forvalues i  = 1 / 9 {
  2.   recode jumlah_art`i' (. = 0)
  3.   rename jumlah_art`i' jumlah_art`i'_udb
  4. }
(204,001 changes made to jumlah_art1)
(204,001 changes made to jumlah_art2)
(204,001 changes made to jumlah_art3)
(204,001 changes made to jumlah_art4)
(204,001 changes made to jumlah_art5)
(204,001 changes made to jumlah_art6)
(204,001 changes made to jumlah_art7)
(204,001 changes made to jumlah_art8)
(204,001 changes made to jumlah_art9)

. 
. // create missing indicator
. gen jumlah_art_m_udb = jumlah_art == .

. 
. 
. ** jumlah_keluarga: number of families in HH
. // by my reading, 0 families should be impossible (every individual belongs to a family); I recode to 0
. replace jumlah_keluarga = . if jumlah_keluarga == 0
(34 real changes made, 34 to missing)

. 
. // create dummies
. tab jumlah_keluarga, gen(jumlah_keluarga)

     Jumlah |
   Keluarga |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |    100,035       89.62       89.62
          2 |     10,289        9.22       98.84
          3 |      1,091        0.98       99.81
          4 |        127        0.11       99.93
          5 |         52        0.05       99.97
          6 |         15        0.01       99.99
          7 |          7        0.01       99.99
          8 |          4        0.00      100.00
          9 |          1        0.00      100.00
         15 |          1        0.00      100.00
------------+-----------------------------------
      Total |    111,622      100.00

. 
. // create indicator for 4+ category
. gen jumlah_keluarga4up_udb = jumlah_keluarga >= 4 & jumlah_keluarga != .

. tab jumlah_keluarga4up_udb

jumlah_kelu |
arga4up_udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    315,465       99.93       99.93
          1 |        207        0.07      100.00
------------+-----------------------------------
      Total |    315,672      100.00

. 
. // set missings to 0
. forvalues i  = 1 / 3 {
  2.   recode jumlah_keluarga`i' (. = 0)
  3.   rename jumlah_keluarga`i' jumlah_keluarga`i'_udb
  4. }
(204,050 changes made to jumlah_keluarga1)
(204,050 changes made to jumlah_keluarga2)
(204,050 changes made to jumlah_keluarga3)

. 
. // create missing indicator
. gen jumlah_keluarga_m_udb = jumlah_keluarga == .

. tab jumlah_keluarga_m_udb

jumlah_kelu |
 arga_m_udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    111,622       35.36       35.36
          1 |    204,050       64.64      100.00
------------+-----------------------------------
      Total |    315,672      100.00

. 
. summ jumlah_keluarga*udb

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
jumla~a1_udb |    315,672    .3168954     .465267          0          1
jumla~a2_udb |    315,672     .032594    .1775717          0          1
jumla~a3_udb |    315,672    .0034561    .0586872          0          1
juml~4up_udb |    315,672    .0006557    .0255991          0          1
jum~ga_m_udb |    315,672    .6463988     .478088          0          1

. 
. ** luas_lantai: floor area
. destring luas_lantai, replace
luas_lantai: all characters numeric; replaced as int
(205165 missing values generated)

. summ luas_lantai

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 luas_lantai |    110,507    51.60485    30.91706          0        912

. recode luas_lantai (. = 0), gen(luas_lantai_udb)
(205,165 differences between luas_lantai and luas_lantai_udb)

. 
. // missing indicator
. gen luas_lantai_m_udb = luas_lantai == .

. 
. ** jumlah_kamar: number of rooms
. // create dummies, treating as categorical variable (4+ combined)
. tab jumlah_kamar, gen(jumlah_kamar)

  6. Jumlah |
      kamar |
     tidur: |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      4,198        3.80        3.80
          1 |     26,786       24.25       28.05
          2 |     50,983       46.15       74.19
          3 |     24,456       22.14       96.33
          4 |      3,435        3.11       99.44
          5 |        454        0.41       99.85
          6 |        116        0.10       99.95
          7 |         28        0.03       99.98
          8 |          8        0.01       99.99
          9 |          9        0.01       99.99
         25 |          1        0.00      100.00
         32 |          1        0.00      100.00
         36 |          1        0.00      100.00
         64 |          1        0.00      100.00
         72 |          1        0.00      100.00
         90 |          1        0.00      100.00
------------+-----------------------------------
      Total |    110,479      100.00

. 
. // rename dummies to match values
. forval i = 1 / `r(r)' {
  2.   local j = `i' - 1
  3.   rename jumlah_kamar`i' jumlah_kamar`j'
  4. }

. 
. // create 4+ category
. gen jumlah_kamar4up_udb = jumlah_kamar >= 4 & jumlah_kamar != .

. tab jumlah_kamar4up_udb

jumlah_kama |
   r4up_udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    311,616       98.72       98.72
          1 |      4,056        1.28      100.00
------------+-----------------------------------
      Total |    315,672      100.00

. 
. // recode missings to 0
. forval i = 0 / 3 {
  2.   recode jumlah_kamar`i' (. = 0)
  3.   rename jumlah_kamar`i' jumlah_kamar`i'_udb
  4. }
(205,193 changes made to jumlah_kamar0)
(205,193 changes made to jumlah_kamar1)
(205,193 changes made to jumlah_kamar2)
(205,193 changes made to jumlah_kamar3)

. 
. // create missing indicator
. gen jumlah_kamar_m_udb = jumlah_kamar == .

. 
. summ jumlah_kamar*udb

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
jumlah~0_udb |    315,672    .0132986    .1145504          0          1
jumla~r1_udb |    315,672    .0848539    .2786646          0          1
jumla~r2_udb |    315,672    .1615062    .3679978          0          1
jumla~r3_udb |    315,672    .0774728    .2673406          0          1
jum~r4up_udb |    315,672    .0128488    .1126221          0          1
-------------+---------------------------------------------------------
juml~r_m_udb |    315,672    .6500196    .4769642          0          1

. 
. 
. ** luas_atb: land area
. replace luas_atb = "" if luas_atb == "-"
(77 real changes made)

. destring luas_atb, replace
luas_atb: all characters numeric; replaced as long
(220898 missing values generated)

. 
. // examine outliers in luas_atb
. summ luas_atb, d

                       5.3a Luas Lahan
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%           12              0
10%           40              0       Obs              94,774
25%           80              0       Sum of wgt.      94,774

50%          300                      Mean           3109.171
                        Largest       Std. dev.      6864.016
75%         2600          99999
90%        10000          99999       Variance       4.71e+07
95%        15000          99999       Skewness        4.84161
99%        30350          99999       Kurtosis       38.72884

. gen luas_atb_z = (luas_atb - `r(mean)') / `r(sd)'
(220,898 missing values generated)

. summ luas_atb_z

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  luas_atb_z |     94,774   -8.26e-10           1  -.4529668   14.11562

. cap noi extremes luas_atb luas_atb_z, high n(25)

  +-------------------------------+
  |    obs:   luas_atb   luas_a~z |
  |-------------------------------|
  | 249677.      90000   12.65889 |
  | 254080.      90000   12.65889 |
  | 270508.      90000   12.65889 |
  | 273227.      90000   12.65889 |
  | 274911.      90000   12.65889 |
  |-------------------------------|
  | 277247.      90000   12.65889 |
  | 292205.      90000   12.65889 |
  |  61708.      90100   12.67346 |
  |  61700.      90200   12.68803 |
  |  62881.      90200   12.68803 |
  |-------------------------------|
  | 235293.      90450   12.72445 |
  | 222465.      95000   13.38733 |
  | 211074.      97650    13.7734 |
  |  63361.      98000   13.82439 |
  | 243960.      98000   13.82439 |
  |-------------------------------|
  | 277766.      98004   13.82497 |
  |   9959.      99000   13.97008 |
  |   9962.      99000   13.97008 |
  | 218346.      99998   14.11547 |
  | 233326.      99998   14.11547 |
  |-------------------------------|
  | 219695.      99999   14.11562 |
  | 227167.      99999   14.11562 |
  | 239628.      99999   14.11562 |
  | 240842.      99999   14.11562 |
  | 240851.      99999   14.11562 |
  +-------------------------------+

note: 16 values of 90000

. 
. // winsorize luas_atb
. gen luas_atb_udb = luas_atb
(220,898 missing values generated)

. _pctile luas_atb, p(99.5)

. replace luas_atb_udb = `r(r1)' if luas_atb_udb > `r(r1)' & !missing(luas_atb_udb)
(473 real changes made)

. summ luas_atb_udb

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
luas_atb_udb |     94,774    3026.427    6182.908          0      42500

. 
. // Create missing luas_atb variable
. gen luas_atb_m_udb = luas_atb == .

. tab luas_atb_m_udb

luas_atb_m_ |
        udb |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     94,774       30.02       30.02
          1 |    220,898       69.98      100.00
------------+-----------------------------------
      Total |    315,672      100.00

. 
. // Replace . = 0
. replace luas_atb_udb = 0 if luas_atb_udb == .
(220,898 real changes made)

. 
. *** Keep lasso-prepped vars and save
. keep renum r103 r104 *udb

. 
. // make sure that no missing values
. foreach var of varlist *udb {
  2.   assert `var' != .
  3. }

. 
. tempfile mar_2019_rt

. save `mar_2019_rt'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.000008 saved as .dta format

. 
. *** Create Head of HH variables from individual survey
. u "$udb_mar19/SSN_BDT_KOR1903_ID_FULL", clear

. keep fwt-source_name

. ds
fwt           tgllahir      sta_kawin     jenis_cacat   ijazah_ter~i  sta_kebera~t  ada_pkh       omset_usaha
renum         hub_krt       ada_akta_n~h  penyakit_k~s  sta_bekerja   sta_kepese~i  ada_rastra    flag_ada_~15
idbdt         nuk           ada_dikk      partisipas~h  jumlah_jam~a  ada_kks       lapangan_u~t  match
idartbdt      hubkel        ada_kartu_~s  pendidikan~i  lapangan_u~a  ada_pbi       jumlah_pek~a  source_nik
jnskel        umur          sta_hamil     kelas_tert~i  status_pek~n  ada_kip       lokasi_usaha  source_name

. 
. * Head of HH
. gen head_hh = hub_krt == 1

. tab head_hh

    head_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |  1,123,649       93.29       93.29
          1 |     80,817        6.71      100.00
------------+-----------------------------------
      Total |  1,204,466      100.00

. 
. * Age of head of HH
. gen age = umur if head_hh == 1
(1,123,670 missing values generated)

. summ age

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
         age |     80,796    48.31446    12.94674          0        138

. // _pctile age, p(0.5 99.5)
. // replace age = `r(r1)' if age < `r(r1)'
. // replace age = `r(r2)' if age > `r(r2)' & !missing(age)
. // summ age
. 
. * keep only head of HH observations
. // some HHs report more than one HoH for some reason
. // when this is the case, I make the oldest one the head of household
. bysort renum: egen head_hh_check = total(head_hh)

. count if head_hh_check > 1
  8,242

. 
. bysort renum (age): gen head_hh_fix = _n == _N if head_hh == 1
(1,123,649 missing values generated)

. tab head_hh_fix head_hh

head_hh_fi |  head_hh
         x |         1 |     Total
-----------+-----------+----------
         0 |    76,677 |    76,677 
         1 |     4,140 |     4,140 
-----------+-----------+----------
     Total |    80,817 |    80,817 

. replace head_hh = head_hh_fix if head_hh_check > 1
(8,179 real changes made, 5,350 to missing)

. tab head_hh_fix head_hh

head_hh_fi |        head_hh
         x |         0          1 |     Total
-----------+----------------------+----------
         0 |     2,829     73,848 |    76,677 
         1 |         0      4,140 |     4,140 
-----------+----------------------+----------
     Total |     2,829     77,988 |    80,817 

. 
. keep if head_hh == 1
(1,126,478 observations deleted)

. 
. * Male head of HH
. gen male = jnskel == 1

. replace male = . if jnskel == .
(30 real changes made, 30 to missing)

. 
. * HoH marital status
. tab sta_kawin, gen(sta_kawin)

  sta_kawin |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          2        0.00        0.00
          1 |        989        1.28        1.28
          2 |     62,948       81.25       82.53
          3 |      2,372        3.06       85.60
          4 |     11,159       14.40      100.00
------------+-----------------------------------
      Total |     77,470      100.00

. 
. * education level of edu reached
. tab pendidikan_tertinggi

pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        830        1.17        1.17
          1 |     44,174       62.36       63.53
          2 |        246        0.35       63.88
          3 |        665        0.94       64.82
          4 |     12,382       17.48       82.30
          5 |        144        0.20       82.50
          6 |        632        0.89       83.39
          7 |     10,498       14.82       98.21
          8 |        279        0.39       98.61
          9 |        285        0.40       99.01
         10 |        598        0.84       99.85
         11 |          1        0.00       99.85
         99 |        103        0.15      100.00
------------+-----------------------------------
      Total |     70,837      100.00

. recode pendidikan_tertinggi (99 = .)
(103 changes made to pendidikan_tertinggi)

. tab pendidikan_tertinggi, gen(pendidikan_tertinggi)

pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        830        1.17        1.17
          1 |     44,174       62.45       63.62
          2 |        246        0.35       63.97
          3 |        665        0.94       64.91
          4 |     12,382       17.51       82.42
          5 |        144        0.20       82.62
          6 |        632        0.89       83.51
          7 |     10,498       14.84       98.36
          8 |        279        0.39       98.75
          9 |        285        0.40       99.15
         10 |        598        0.85      100.00
         11 |          1        0.00      100.00
------------+-----------------------------------
      Total |     70,734      100.00

. summ pendidikan_tertinggi?*

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
pendidika~i1 |     70,734    .0117341    .1076874          0          1
pendidika~i2 |     70,734    .6245087    .4842529          0          1
pendidikan~3 |     70,734    .0034778    .0588708          0          1
pendidikan~4 |     70,734    .0094014    .0965047          0          1
pendidikan~5 |     70,734    .1750502    .3800127          0          1
-------------+---------------------------------------------------------
pendidikan~6 |     70,734    .0020358    .0450742          0          1
pendidikan~7 |     70,734    .0089349    .0941019          0          1
pendidikan~8 |     70,734    .1484152    .3555136          0          1
pendidikan~9 |     70,734    .0039444    .0626806          0          1
pendidika~10 |     70,734    .0040292    .0633483          0          1
-------------+---------------------------------------------------------
pendidika~11 |     70,734    .0084542    .0915579          0          1
pendidika~12 |     70,734    .0000141      .00376          0          1

. 
. * highest grade ever reached
. tab kelas_tertinggi, gen(kelas_tertinggi)

kelas_terti |
       nggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        834        1.18        1.18
          1 |      2,727        3.85        5.03
          2 |      4,334        6.12       11.15
          3 |      4,739        6.69       17.84
          4 |      3,183        4.49       22.33
          5 |      3,554        5.02       27.35
          6 |      2,000        2.82       30.18
          7 |         20        0.03       30.20
          8 |     49,431       69.80      100.00
          9 |          1        0.00      100.00
------------+-----------------------------------
      Total |     70,823      100.00

. 
. * highest diploma received
. tab ijazah_tertinggi, gen(ijazah_tertinggi)

ijazah_tert |
      inggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     16,380       23.13       23.13
          1 |     29,979       42.33       65.46
          2 |     12,948       18.28       83.74
          3 |     10,370       14.64       98.38
          4 |        806        1.14       99.52
          5 |        321        0.45       99.97
          6 |         20        0.03      100.00
------------+-----------------------------------
      Total |     70,824      100.00

. 
. * work status
. tab sta_bekerja

sta_bekerja |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         33        0.04        0.04
          1 |     66,029       85.23       85.28
          2 |     11,406       14.72      100.00
------------+-----------------------------------
      Total |     77,468      100.00

. gen worked = sta_bekerja == 1

. replace worked = . if sta_bekerja == .
(520 real changes made, 520 to missing)

. 
. * hours worked
. summ jumlah_jamkerja

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
jumlah_jam~a |     67,695    36.43206    17.61625         -1        105

. recode jumlah_jamkerja (-1 = .)
(6 changes made to jumlah_jamkerja)

. 
. * field of business
. tab lapangan_usaha

lapangan_us |
        aha |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,659        2.45        2.45
          1 |     19,626       28.98       31.43
          2 |      1,567        2.31       33.74
          3 |     12,729       18.80       52.54
          4 |      2,847        4.20       56.75
          5 |        466        0.69       57.43
          6 |      1,306        1.93       59.36
          7 |        716        1.06       60.42
          8 |        875        1.29       61.71
          9 |      3,165        4.67       66.39
         10 |        127        0.19       66.57
         11 |      6,853       10.12       76.69
         12 |      4,739        7.00       83.69
         13 |        657        0.97       84.66
         14 |      3,155        4.66       89.32
         15 |         52        0.08       89.40
         16 |         66        0.10       89.49
         17 |        286        0.42       89.92
         18 |         76        0.11       90.03
         19 |      4,222        6.23       96.26
         20 |        233        0.34       96.61
         21 |      2,298        3.39      100.00
------------+-----------------------------------
      Total |     67,720      100.00

. recode lapangan_usaha (0 = .)
(1,659 changes made to lapangan_usaha)

. tab lapangan_usaha, gen(lapangan_usaha)

lapangan_us |
        aha |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     19,626       29.71       29.71
          2 |      1,567        2.37       32.08
          3 |     12,729       19.27       51.35
          4 |      2,847        4.31       55.66
          5 |        466        0.71       56.36
          6 |      1,306        1.98       58.34
          7 |        716        1.08       59.43
          8 |        875        1.32       60.75
          9 |      3,165        4.79       65.54
         10 |        127        0.19       65.73
         11 |      6,853       10.37       76.11
         12 |      4,739        7.17       83.28
         13 |        657        0.99       84.28
         14 |      3,155        4.78       89.05
         15 |         52        0.08       89.13
         16 |         66        0.10       89.23
         17 |        286        0.43       89.66
         18 |         76        0.12       89.78
         19 |      4,222        6.39       96.17
         20 |        233        0.35       96.52
         21 |      2,298        3.48      100.00
------------+-----------------------------------
      Total |     66,061      100.00

. 
. * job status
. tab status_pekerjaan

status_peke |
      rjaan |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,664        2.46        2.46
          1 |     21,955       32.43       34.89
          2 |     15,846       23.40       58.29
          3 |      1,013        1.50       59.79
          4 |     12,704       18.76       78.55
          5 |        118        0.17       78.72
          6 |      7,200       10.63       89.36
          7 |      6,500        9.60       98.96
          8 |        705        1.04      100.00
------------+-----------------------------------
      Total |     67,705      100.00

. recode status_pekerjaan (0 = .)
(1,664 changes made to status_pekerjaan)

. tab status_pekerjaan, gen(status_pekerjaan)

status_peke |
      rjaan |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     21,955       33.24       33.24
          2 |     15,846       23.99       57.24
          3 |      1,013        1.53       58.77
          4 |     12,704       19.24       78.01
          5 |        118        0.18       78.19
          6 |      7,200       10.90       89.09
          7 |      6,500        9.84       98.93
          8 |        705        1.07      100.00
------------+-----------------------------------
      Total |     66,041      100.00

. 
. keep renum status_pekerjaan?* lapangan_usaha? lapangan_usaha?? worked jumlah_jamkerja ijazah_tertinggi? kelas_tertinggi? 
> ///
>   pendidikan_tertinggi? pendidikan_tertinggi?? sta_kawin male age

. rename * *_hoh_udb

. rename renum_hoh_udb renum

. 
. tempfile head_hh_mar19

. save `head_hh_mar19'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.000009 saved as .dta format

. 
. 
. *** Create overall household variables from individual survey
. u "$udb_mar19/SSN_BDT_KOR1903_ID_FULL", clear

. keep fwt-source_name

. gen udb = idbdt != ""

. keep if udb == 1
(909,624 observations deleted)

. 
. * pregnancy status
. tab sta_hamil

  sta_hamil |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     21,706       27.54       27.54
          1 |      2,649        3.36       30.90
          2 |     54,458       69.10      100.00
------------+-----------------------------------
      Total |     78,813      100.00

. gen pregnant = sta_hamil == 1

. gen pregnant_m = sta_hamil == .

. 
. * disability type
. tab jenis_cacat

jenis_cacat |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    288,474       98.70       98.70
          1 |      1,060        0.36       99.07
          2 |        470        0.16       99.23
          3 |        341        0.12       99.34
          4 |        313        0.11       99.45
          5 |        158        0.05       99.51
          6 |         97        0.03       99.54
          7 |         29        0.01       99.55
          8 |         74        0.03       99.57
          9 |         51        0.02       99.59
         10 |        579        0.20       99.79
         11 |        188        0.06       99.85
         12 |        428        0.15      100.00
------------+-----------------------------------
      Total |    292,262      100.00

. gen disability = 1 <= jenis_cacat & jenis_cacat <= 12

. gen disability_m = jenis_cacat == .

. 
. * chronic disease
. tab penyakit_kronis

penyakit_kr |
       onis |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    279,881       95.76       95.76
          1 |      2,870        0.98       96.75
          2 |      4,272        1.46       98.21
          3 |      1,380        0.47       98.68
          4 |        436        0.15       98.83
          5 |        486        0.17       98.99
          6 |        227        0.08       99.07
          7 |        544        0.19       99.26
          8 |        180        0.06       99.32
          9 |      1,987        0.68      100.00
------------+-----------------------------------
      Total |    292,263      100.00

. gen chronic_disease = 1 <= penyakit_kronis & penyakit_kronis <= 9

. gen chronic_disease_m = penyakit_kronis == .

. 
. * number in school
. gen in_school = partisipasi_sekolah == 1

. gen in_school_m = partisipasi_sekolah == .

. 
. * highest level of education completed
. tab pendidikan_tertinggi

pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      4,646        1.84        1.84
          1 |    140,288       55.61       57.45
          2 |        823        0.33       57.77
          3 |      2,993        1.19       58.96
          4 |     49,879       19.77       78.73
          5 |        429        0.17       78.90
          6 |      3,749        1.49       80.39
          7 |     41,957       16.63       97.02
          8 |        672        0.27       97.28
          9 |      1,664        0.66       97.94
         10 |      4,304        1.71       99.65
         11 |          1        0.00       99.65
         99 |        883        0.35      100.00
------------+-----------------------------------
      Total |    252,288      100.00

. recode pendidikan_tertinggi (99 = .)
(883 changes made to pendidikan_tertinggi)

. 
. * highest grade ever reached
. tab kelas_tertinggi

kelas_terti |
       nggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      4,689        1.86        1.86
          1 |     23,730        9.41       11.27
          2 |     26,754       10.61       21.87
          3 |     24,903        9.87       31.75
          4 |     14,126        5.60       37.35
          5 |     15,022        5.96       43.30
          6 |     10,867        4.31       47.61
          7 |        187        0.07       47.69
          8 |    131,944       52.31      100.00
          9 |          7        0.00      100.00
         10 |          1        0.00      100.00
         12 |          4        0.00      100.00
------------+-----------------------------------
      Total |    252,234      100.00

. 
. * highest degree
. tab ijazah_tertinggi

ijazah_tert |
      inggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     77,577       30.76       30.76
          1 |     89,641       35.54       66.29
          2 |     44,824       17.77       84.06
          3 |     35,038       13.89       97.96
          4 |      3,305        1.31       99.27
          5 |      1,715        0.68       99.95
          6 |        133        0.05      100.00
          9 |          4        0.00      100.00
------------+-----------------------------------
      Total |    252,237      100.00

. 
. * worked in past week
. tab sta_bekerja

sta_bekerja |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        428        0.16        0.16
          1 |    122,557       44.62       44.78
          2 |    151,667       55.22      100.00
------------+-----------------------------------
      Total |    274,652      100.00

. gen work = sta_bekerja
(20,190 missing values generated)

. recode work (2 = 0)
(151,667 changes made to work)

. gen work_m = sta_bekerja == .

. 
. * number in HH
. preserve

. bysort renum: gen num_in_hh = _N

. summ num_in_hh

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
   num_in_hh |    294,842    3.414703    1.535165          1         12

. keep renum num_in_hh

. duplicates drop

Duplicates in terms of all variables

(182,779 observations deleted)

. di _N
112063

. tempfile num_hh

. save `num_hh'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.00000b saved as .dta format

. restore

. 
. // merge in number in HH
. merge m:1 renum using `num_hh'

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                           294,842  (_merge==3)
    -----------------------------------------

. assert _m != 2

. drop _m

. 
. tab num_in_hh, gen(num_in_hh)

  num_in_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     30,003       10.18       10.18
          2 |     55,698       18.89       29.07
          3 |     75,831       25.72       54.79
          4 |     68,736       23.31       78.10
          5 |     38,750       13.14       91.24
          6 |     16,260        5.51       96.76
          7 |      6,335        2.15       98.90
          8 |      2,280        0.77       99.68
          9 |        585        0.20       99.88
         10 |        250        0.08       99.96
         11 |         66        0.02       99.98
         12 |         48        0.02      100.00
------------+-----------------------------------
      Total |    294,842      100.00

. 
. // keep vars
. keep renum pregnant disability chronic_disease in_school work pendidikan_tertinggi kelas_tertinggi ijazah_tertinggi num_i
> n_hh? num_in_hh?? *_m

. 
. 
. // collapse to HH level
. collapse (sum) pregnant disability chronic_disease in_school work (max) max_edu_in_hh = pendidikan_tertinggi max_grade_in
> _hh = kelas_tertinggi ///
>   max_degree_in_hh = ijazah_tertinggi (mean) num_in_hh? num_in_hh?? *_m, by(renum)

. summ

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       renum |    112,063    150100.5    87779.78          1     315641
    pregnant |    112,063    .0236385    .1542524          0          4
  disability |    112,063    .0338024    .1926705          0          5
chronic_di~e |    112,063    .1104914    .3759409          0          7
   in_school |    112,063    .6307256    .8588767          0          8
-------------+---------------------------------------------------------
        work |    112,063    1.093644    .8377254          0          9
max_edu_in~h |    105,213    4.051553    2.810504          0         11
max_grade_~h |    105,377     6.92002     2.08608          0         12
max_degree~h |    105,378    1.733369    1.151791          0          9
  num_in_hh1 |    112,063    .2677333    .4427798          0          1
-------------+---------------------------------------------------------
  num_in_hh2 |    112,063     .248512    .4321521          0          1
  num_in_hh3 |    112,063    .2255606    .4179529          0          1
  num_in_hh4 |    112,063    .1533423    .3603188          0          1
  num_in_hh5 |    112,063    .0691575     .253723          0          1
  num_in_hh6 |    112,063    .0241828    .1536171          0          1
-------------+---------------------------------------------------------
  num_in_hh7 |    112,063    .0080758    .0895023          0          1
  num_in_hh8 |    112,063    .0025432    .0503663          0          1
  num_in_hh9 |    112,063      .00058     .024077          0          1
 num_in_hh10 |    112,063    .0002231    .0149346          0          1
 num_in_hh11 |    112,063    .0000535     .007317          0          1
-------------+---------------------------------------------------------
 num_in_hh12 |    112,063    .0000357    .0059744          0          1
  pregnant_m |    112,063    .7460095    .3327398          0          1
disability_m |    112,063    .0112178    .1005699          0          1
chronic_di~m |    112,063    .0112169    .1005695          0          1
 in_school_m |    112,063    .0584582    .1631417          0          1
-------------+---------------------------------------------------------
      work_m |    112,063    .0585969    .1633112          0          1

. 
. di _N
112063

. * Create education variables categories
. tab max_edu_in_hh, gen(max_edu_in_hh)

      (max) |
pendidikan_ |
  tertinggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        694        0.66        0.66
          1 |     39,238       37.29       37.95
          2 |        391        0.37       38.33
          3 |      1,059        1.01       39.33
          4 |     25,288       24.04       63.37
          5 |        283        0.27       63.64
          6 |      2,419        2.30       65.93
          7 |     29,928       28.45       94.38
          8 |        600        0.57       94.95
          9 |      1,429        1.36       96.31
         10 |      3,883        3.69      100.00
         11 |          1        0.00      100.00
------------+-----------------------------------
      Total |    105,213      100.00

. tab max_grade_in_hh, gen(max_grade_in_hh)

      (max) |
kelas_terti |
       nggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        706        0.67        0.67
          1 |      2,787        2.64        3.31
          2 |      4,096        3.89        7.20
          3 |      5,302        5.03       12.23
          4 |      3,728        3.54       15.77
          5 |      4,907        4.66       20.43
          6 |      3,943        3.74       24.17
          7 |         66        0.06       24.23
          8 |     79,832       75.76       99.99
          9 |          5        0.00      100.00
         10 |          1        0.00      100.00
         12 |          4        0.00      100.00
------------+-----------------------------------
      Total |    105,377      100.00

. tab max_degree_in_hh, gen(max_degree_in_hh)

      (max) |
ijazah_tert |
      inggi |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     14,946       14.18       14.18
          1 |     34,622       32.86       47.04
          2 |     25,605       24.30       71.34
          3 |     25,848       24.53       95.87
          4 |      2,643        2.51       98.37
          5 |      1,585        1.50       99.88
          6 |        125        0.12      100.00
          9 |          4        0.00      100.00
------------+-----------------------------------
      Total |    105,378      100.00

. 
. * Create 1+ in HH dummy
. foreach var of varlist pregnant disability chronic_disease in_school work {
  2.   gen `var'_hh = `var' >= 1
  3. 
.   // replace = missing if all obs within HH are missing
.   replace `var'_hh = . if `var'_m == 1
  4.   tab `var'_hh
  5. }
(54,447 real changes made, 54,447 to missing)

pregnant_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     54,996       95.45       95.45
          1 |      2,620        4.55      100.00
------------+-----------------------------------
      Total |     57,616      100.00
(1,046 real changes made, 1,046 to missing)

disability_ |
         hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    107,449       96.79       96.79
          1 |      3,568        3.21      100.00
------------+-----------------------------------
      Total |    111,017      100.00
(1,046 real changes made, 1,046 to missing)

chronic_dis |
    ease_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    100,783       90.78       90.78
          1 |     10,234        9.22      100.00
------------+-----------------------------------
      Total |    111,017      100.00
(1,648 real changes made, 1,648 to missing)

in_school_h |
          h |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     61,634       55.82       55.82
          1 |     48,781       44.18      100.00
------------+-----------------------------------
      Total |    110,415      100.00
(1,652 real changes made, 1,652 to missing)

    work_hh |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     24,805       22.47       22.47
          1 |     85,606       77.53      100.00
------------+-----------------------------------
      Total |    110,411      100.00

. 
. keep renum pregnant_hh disability_hh chronic_disease_hh in_school_hh work_hh max_edu_in_hh? max_edu_in_hh?? max_grade_in_
> hh? max_degree_in_hh? num_in_hh? num_in_hh??

. rename * *_udb

. rename renum_udb renum

. 
. tempfile overall_hh_mar19

. save `overall_hh_mar19'
file /var/folders/23/7_md6wbn6ns7m_ppp9yb96sh0000gp/T//S_18300.00000c saved as .dta format

. 
. ** Merge in vars from individual datasets
. u `mar_2019_rt', clear

. 
. * merge in Head of HH vars
. merge 1:1 renum using `head_hh_mar19'

    Result                      Number of obs
    -----------------------------------------
    Not matched                       237,684
        from master                   237,684  (_merge==1)
        from using                          0  (_merge==2)

    Matched                            77,988  (_merge==3)
    -----------------------------------------

. assert _m != 2

. drop _m

. 
. // create missing indicators
. foreach stub in status_pekerjaan lapangan_usaha ijazah_tertinggi kelas_tertinggi pendidikan_tertinggi {
  2.   gen `stub'_hoh_m_udb = `stub'1_hoh_udb == .
  3.   summ `stub'_hoh_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
status~m_udb |    315,672    .7907923    .4067436          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
lapang~m_udb |    315,672     .790729    .4067889          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
ijazah~m_udb |    315,672    .7756405    .4171605          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
kelas_~m_udb |    315,672    .7756437    .4171584          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
pendid~m_udb |    315,672    .7759256    .4169719          0          1

. 
. foreach stub in worked jumlah_jamkerja sta_kawin male age {
  2.   gen `stub'_hoh_m_udb = `stub'_hoh_udb == .
  3.   summ `stub'_hoh_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
worked~m_udb |    315,672    .7545934    .4303287          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
juml~h_m_udb |    315,672    .7855717    .4104258          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
sta_ka~m_udb |    315,672     .754587    .4303325          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
male_hoh_m~b |    315,672    .7530411    .4312433          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
age_hoh_m_~b |    315,672    .7530095    .4312619          0          1

. 
. // replace missings with 0s
. foreach var of varlist status_pekerjaan?_hoh_udb lapangan_usaha?_hoh_udb lapangan_usaha??_hoh_udb ijazah_tertinggi?_hoh_u
> db kelas_tertinggi?_hoh_udb ///
>   pendidikan_tertinggi?_hoh_udb pendidikan_tertinggi??_hoh_udb worked_hoh_udb jumlah_jamkerja_hoh_udb sta_kawin_hoh_udb m
> ale_hoh_udb age_hoh_udb {
  2.     recode `var' (. = 0)
  3.   }
(249,631 changes made to status_pekerjaan1_hoh_udb)
(249,631 changes made to status_pekerjaan2_hoh_udb)
(249,631 changes made to status_pekerjaan3_hoh_udb)
(249,631 changes made to status_pekerjaan4_hoh_udb)
(249,631 changes made to status_pekerjaan5_hoh_udb)
(249,631 changes made to status_pekerjaan6_hoh_udb)
(249,631 changes made to status_pekerjaan7_hoh_udb)
(249,631 changes made to status_pekerjaan8_hoh_udb)
(249,611 changes made to lapangan_usaha1_hoh_udb)
(249,611 changes made to lapangan_usaha2_hoh_udb)
(249,611 changes made to lapangan_usaha3_hoh_udb)
(249,611 changes made to lapangan_usaha4_hoh_udb)
(249,611 changes made to lapangan_usaha5_hoh_udb)
(249,611 changes made to lapangan_usaha6_hoh_udb)
(249,611 changes made to lapangan_usaha7_hoh_udb)
(249,611 changes made to lapangan_usaha8_hoh_udb)
(249,611 changes made to lapangan_usaha9_hoh_udb)
(249,611 changes made to lapangan_usaha10_hoh_udb)
(249,611 changes made to lapangan_usaha11_hoh_udb)
(249,611 changes made to lapangan_usaha12_hoh_udb)
(249,611 changes made to lapangan_usaha13_hoh_udb)
(249,611 changes made to lapangan_usaha14_hoh_udb)
(249,611 changes made to lapangan_usaha15_hoh_udb)
(249,611 changes made to lapangan_usaha16_hoh_udb)
(249,611 changes made to lapangan_usaha17_hoh_udb)
(249,611 changes made to lapangan_usaha18_hoh_udb)
(249,611 changes made to lapangan_usaha19_hoh_udb)
(249,611 changes made to lapangan_usaha20_hoh_udb)
(249,611 changes made to lapangan_usaha21_hoh_udb)
(244,848 changes made to ijazah_tertinggi1_hoh_udb)
(244,848 changes made to ijazah_tertinggi2_hoh_udb)
(244,848 changes made to ijazah_tertinggi3_hoh_udb)
(244,848 changes made to ijazah_tertinggi4_hoh_udb)
(244,848 changes made to ijazah_tertinggi5_hoh_udb)
(244,848 changes made to ijazah_tertinggi6_hoh_udb)
(244,848 changes made to ijazah_tertinggi7_hoh_udb)
(244,849 changes made to kelas_tertinggi1_hoh_udb)
(244,849 changes made to kelas_tertinggi2_hoh_udb)
(244,849 changes made to kelas_tertinggi3_hoh_udb)
(244,849 changes made to kelas_tertinggi4_hoh_udb)
(244,849 changes made to kelas_tertinggi5_hoh_udb)
(244,849 changes made to kelas_tertinggi6_hoh_udb)
(244,849 changes made to kelas_tertinggi7_hoh_udb)
(244,849 changes made to kelas_tertinggi8_hoh_udb)
(244,849 changes made to kelas_tertinggi9_hoh_udb)
(244,938 changes made to pendidikan_tertinggi1_hoh_udb)
(244,938 changes made to pendidikan_tertinggi2_hoh_udb)
(244,938 changes made to pendidikan_tertinggi3_hoh_udb)
(244,938 changes made to pendidikan_tertinggi4_hoh_udb)
(244,938 changes made to pendidikan_tertinggi5_hoh_udb)
(244,938 changes made to pendidikan_tertinggi6_hoh_udb)
(244,938 changes made to pendidikan_tertinggi7_hoh_udb)
(244,938 changes made to pendidikan_tertinggi8_hoh_udb)
(244,938 changes made to pendidikan_tertinggi9_hoh_udb)
(244,938 changes made to pendidikan_tertinggi10_hoh_udb)
(244,938 changes made to pendidikan_tertinggi11_hoh_udb)
(244,938 changes made to pendidikan_tertinggi12_hoh_udb)
(238,204 changes made to worked_hoh_udb)
(247,983 changes made to jumlah_jamkerja_hoh_udb)
(238,202 changes made to sta_kawin_hoh_udb)
(237,714 changes made to male_hoh_udb)
(237,704 changes made to age_hoh_udb)

. 
. * merge in overall HH vars
. merge 1:1 renum using `overall_hh_mar19'

    Result                      Number of obs
    -----------------------------------------
    Not matched                       203,609
        from master                   203,609  (_merge==1)
        from using                          0  (_merge==2)

    Matched                           112,063  (_merge==3)
    -----------------------------------------

. assert _m != 2

. drop _m

. 
. // create missing indicators
. foreach stub in pregnant_hh disability_hh chronic_disease_hh in_school_hh work_hh {
  2.   gen `stub'_m_udb = `stub'_udb == .
  3.   summ `stub'_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
pregna~m_udb |    315,672    .8174814    .3862719          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
disabi~m_udb |    315,672    .6483153    .4774969          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
chroni~m_udb |    315,672    .6483153    .4774969          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
in_sch~m_udb |    315,672    .6502224    .4769004          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
work_hh_m_~b |    315,672    .6502351    .4768964          0          1

. 
. foreach stub in max_edu_in_hh max_grade_in_hh max_degree_in_hh num_in_hh {
  2.   gen `stub'_m_udb = `stub'1_udb == .
  3.   summ `stub'_m_udb
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
max_ed~m_udb |    315,672    .6667015    .4713929          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
max_gr~m_udb |    315,672     .666182    .4715763          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
max_de~m_udb |    315,672    .6661788    .4715775          0          1

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
num_in_hh_~b |    315,672    .6450018    .4785135          0          1

. 
. // replace missings with 0s
. foreach var of varlist pregnant_hh_udb disability_hh_udb chronic_disease_hh_udb in_school_hh_udb work_hh_udb max_edu_in_h
> h?_udb max_edu_in_hh??_udb ///
>   max_grade_in_hh?_udb max_degree_in_hh?_udb num_in_hh?_udb num_in_hh??_udb {
  2.     recode `var' (. = 0)
  3.   }
(258,056 changes made to pregnant_hh_udb)
(204,655 changes made to disability_hh_udb)
(204,655 changes made to chronic_disease_hh_udb)
(205,257 changes made to in_school_hh_udb)
(205,261 changes made to work_hh_udb)
(210,459 changes made to max_edu_in_hh1_udb)
(210,459 changes made to max_edu_in_hh2_udb)
(210,459 changes made to max_edu_in_hh3_udb)
(210,459 changes made to max_edu_in_hh4_udb)
(210,459 changes made to max_edu_in_hh5_udb)
(210,459 changes made to max_edu_in_hh6_udb)
(210,459 changes made to max_edu_in_hh7_udb)
(210,459 changes made to max_edu_in_hh8_udb)
(210,459 changes made to max_edu_in_hh9_udb)
(210,459 changes made to max_edu_in_hh10_udb)
(210,459 changes made to max_edu_in_hh11_udb)
(210,459 changes made to max_edu_in_hh12_udb)
(0 changes made to max_edu_in_hh_m_udb)
(210,295 changes made to max_grade_in_hh1_udb)
(210,295 changes made to max_grade_in_hh2_udb)
(210,295 changes made to max_grade_in_hh3_udb)
(210,295 changes made to max_grade_in_hh4_udb)
(210,295 changes made to max_grade_in_hh5_udb)
(210,295 changes made to max_grade_in_hh6_udb)
(210,295 changes made to max_grade_in_hh7_udb)
(210,295 changes made to max_grade_in_hh8_udb)
(210,295 changes made to max_grade_in_hh9_udb)
(210,294 changes made to max_degree_in_hh1_udb)
(210,294 changes made to max_degree_in_hh2_udb)
(210,294 changes made to max_degree_in_hh3_udb)
(210,294 changes made to max_degree_in_hh4_udb)
(210,294 changes made to max_degree_in_hh5_udb)
(210,294 changes made to max_degree_in_hh6_udb)
(210,294 changes made to max_degree_in_hh7_udb)
(210,294 changes made to max_degree_in_hh8_udb)
(203,609 changes made to num_in_hh1_udb)
(203,609 changes made to num_in_hh2_udb)
(203,609 changes made to num_in_hh3_udb)
(203,609 changes made to num_in_hh4_udb)
(203,609 changes made to num_in_hh5_udb)
(203,609 changes made to num_in_hh6_udb)
(203,609 changes made to num_in_hh7_udb)
(203,609 changes made to num_in_hh8_udb)
(203,609 changes made to num_in_hh9_udb)
(203,609 changes made to num_in_hh10_udb)
(203,609 changes made to num_in_hh11_udb)
(203,609 changes made to num_in_hh12_udb)
(0 changes made to num_in_hh_m_udb)

. 
. // assert no missings
. foreach var of varlist *udb {
  2.   assert `var' != .
  3. }

. 
. di c(k)
352

. // 352 variables
. save "$cleaned/mar_2019_udb_lasso_pool.dta", replace
file /Users/clotairemit.edu/Dropbox (MIT)/J-PAL Raskin Transition/10_Analysis&Results/Agent Experiment
    Analysis/01_Data/cleaned/mar_2019_udb_lasso_pool.dta saved

. 
. cap log close
